ScholarQuill logoScholarQuillUniversity Notes
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
Study Tools
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
Contact
ScholarQuill logo
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
ScholarQuill logoScholarQuillUniversity Notes
Study PortalCOMP4126Property Lists Persist…
Ctrl + K
Login
Explore
Search
Semester
Papers
CGPA
    COMP4126

    Mobile Application Development 2

    Progress0 / 38 done
    Topics38
    1Understanding Xcode2Using the Xcode interface builder and objects library3Understanding view hierarchy and creating a custom app icon
    4Understanding outlets and actions5Using text fields, buttons, labels, web views, and page controllers6Using views with subviews and creating views using code
    7Working with the single view template8Exploring the app delegate and adding new view controllers9Transitioning between multiple view controllers using animations
    10Tabbar and master detail templates
    11Customizing for different inputs12Adjusting text field behaviors and dismissing the keyboard13Detecting keyboard activities with notification center14Using scroll view and responding to keyboard activities programmatically
    15Detecting device hardware16Dynamically adjusting graphical layouts and creating universal apps
    17Understanding UITableView and UITableViewCell18Working with UITableView data source and delegate19Master detail template, drill-down menus, and navigation20Using property lists for data persistence and creating multi-section tables
    21Portrait and landscape modes22Handling device rotation and forcing specific orientation23Dynamically adjusting layouts based on rotation
    24Importing sqlite3 and creating a database25Writing tables, inserting records, and bundling a database with your app26Checking for database existence and reading/displaying data
    27NSTimer class and object transformations28Rotation, scaling, translation, animating image arrays, and playing video
    29Email, Safari, and SMS30Working with camera and photo library
    31Consuming and parsing XML and JSON32Integrating Twitter and Facebook with iOS apps
    33MapKit and MKMapView34Getting and displaying user location and directional information35Displaying map annotations, disclosure buttons, and reverse geocoding36Working with iCloud
    37Gyroscope and accelerometer38Outputting sensor data and using the Shake API
    4 min read
    Topic 20 of 38
    Topic Study Note Illustration
    20

    Using property lists for data persistence and creating multi-section tables

    A Property List (plist) is a file used in iOS to store structured data in key–value format . It is commonly used for simple data persistence .

    📱 Using Property Lists (Plist) for Data Persistence & Creating Multi-Section Tables (iOS – Xcode)


    ✅ 1. Definition

    🔹 Property List (plist)

    A Property List (plist) is a file used in iOS to store structured data in key–value format. It is commonly used for simple data persistence.

    👉 It stores data like:

    • Arrays
    • Dictionaries
    • Strings, Numbers, Booleans

    📌 File extension: .plist


    🔹 Data Persistence

    Data persistence means saving data so it remains available even after the app is closed and reopened.


    🔹 Multi-Section Table

    A UITableView with multiple sections, where data is grouped into categories.

    👉 Example:

    • Fruits section
    • Vegetables section
    • Drinks section

    🧠 2. Key Concepts

    🔹 Plist Structure

    A plist can be:

    • Dictionary-based
    • Array-based

    Example structure:

    Food
     ├── Fruits
     ├── Vegetables
     └── Drinks
    

    🔹 Table Sections

    A table view contains:

    • Sections (groups)
    • Rows (items inside each section)

    💾 3. Using Property List for Data Persistence


    🔹 Step 1: Create a plist file

    • File → New → Property List
    • Name it: data.plist

    🔹 Step 2: Add Data

    Example plist structure:

    Fruits → Apple, Banana, Mango  
    Vegetables → Carrot, Potato  
    Drinks → Water, Juice
    

    🔹 Step 3: Read Data from plist

    if let path = Bundle.main.path(forResource: "data", ofType: "plist"),
       let dict = NSDictionary(contentsOfFile: path) as? [String: [String]] {
        
        print(dict)
    }
    

    🔹 Step 4: Store Data in Arrays

    var sections: [String] = []
    var data: [[String]] = []
    

    🔹 Step 5: Load Data

    sections = Array(dict.keys)
    data = Array(dict.values)
    

    📊 4. Multi-Section UITableView


    🔹 Step 1: Number of Sections

    func numberOfSections(in tableView: UITableView) -> Int {
        return sections.count
    }
    

    🔹 Step 2: Number of Rows per Section

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return data[section].count
    }
    

    🔹 Step 3: Cell Content

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    
        let cell = UITableViewCell(style: .default, reuseIdentifier: "cell")
        
        cell.textLabel?.text = data[indexPath.section][indexPath.row]
        
        return cell
    }
    

    🔹 Step 4: Section Title

    func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
        return sections[section]
    }
    

    📊 5. Diagram Description (for Exams)

    Draw:

    TableView
     ├── Fruits
     │     ├ Apple
     │     ├ Banana
     │
     ├── Vegetables
     │     ├ Carrot
     │     ├ Potato
     │
     └── Drinks
           ├ Water
           ├ Juice
    

    💡 6. Example App

    🎯 Grocery App

    • Sections:

      • Fruits
      • Vegetables
      • Drinks

    👉 Data stored in plist 👉 Displayed in multi-section table


    📌 7. Important Rules / Tips

    • Plist is good for small static data only
    • Use dictionaries for section-based data
    • Always reload table after loading data
    • Keep data structured (key-value or arrays)
    • Use section titles for better UI

    ⚠️ 8. Common Mistakes

    • ❌ Using plist for large data (not recommended)
    • ❌ Wrong data casting from plist
    • ❌ Not matching section and row data
    • ❌ Forgetting to reload table view
    • ❌ Incorrect indexing (section/row mismatch)

    🧠 9. Best Practices

    • Use plist for:

      • Settings
      • Static lists
    • Use JSON/Core Data for large apps

    • Keep data organized in dictionaries

    • Always validate data before use

    • Use meaningful section names


    📝 10. Likely Exam Questions

    1. What is a Property List (plist)?
    2. How is data stored in plist files?
    3. What is data persistence in iOS?
    4. Explain multi-section table view.
    5. Write code to load data from plist.
    6. How do you define number of sections in UITableView?
    7. What is titleForHeaderInSection used for?
    8. Differentiate between plist and database storage.

    📚 11. Quick Revision Summary

    • Plist = key-value file for storing small data

    • Used for data persistence

    • Multi-section table groups data into categories

    • Key methods:

      • numberOfSections
      • numberOfRowsInSection
      • cellForRowAt
    • Section titles improve UI clarity

    • Best for static data (settings, lists)


    ← Previous topic 19
    Master detail template, drill-down menus, and navigation
    Next topic 21 →
    Supporting Screen Rotations: Portrait and landscape modes

    Past Papers

    Open this section to view and download past papers

    Click on Show Past Papers to load available exam papers.

    Reading Progress
    0%
    4mremaining
    620words
    Beginnerlevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Mobile Application Development 2