ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Mobile Application Development 2
    COMP4126
    Progress0 / 38 topics
    Topics
    1. Creating an iOS App: Understanding Xcode2. Using the Xcode interface builder and objects library3. Understanding view hierarchy and creating a custom app icon4. Outlets, Actions, and Views: Understanding outlets and actions5. Using text fields, buttons, labels, web views, and page controllers6. Using views with subviews and creating views using code7. Using View Controllers: Working with the single view template8. Exploring the app delegate and adding new view controllers9. Transitioning between multiple view controllers using animations10. Application Templates: Tabbar and master detail templates11. The iOS Keyboard: Customizing for different inputs12. Adjusting text field behaviors and dismissing the keyboard13. Detecting keyboard activities with notification center14. Using scroll view and responding to keyboard activities programmatically15. Working with Different iOS Devices (iPhone & iPad): Detecting device hardware16. Dynamically adjusting graphical layouts and creating universal apps17. Using Table Views: Understanding UITableView and UITableViewCell18. Working with UITableView data source and delegate19. Master detail template, drill-down menus, and navigation20. Using property lists for data persistence and creating multi-section tables21. Supporting Screen Rotations: Portrait and landscape modes22. Handling device rotation and forcing specific orientation23. Dynamically adjusting layouts based on rotation24. Working with Databases: Importing sqlite3 and creating a database25. Writing tables, inserting records, and bundling a database with your app26. Checking for database existence and reading/displaying data27. Using Animations & Video: NSTimer class and object transformations28. Rotation, scaling, translation, animating image arrays, and playing video29. Accessing Integrated iOS Apps: Email, Safari, and SMS30. Working with camera and photo library31. Using Web Services: Consuming and parsing XML and JSON32. Integrating Twitter and Facebook with iOS apps33. Working with iOS Maps and Location Services: MapKit and MKMapView34. Getting and displaying user location and directional information35. Displaying map annotations, disclosure buttons, and reverse geocoding36. Working with iCloud37. Working with the Accelerometer: Gyroscope and accelerometer38. Outputting sensor data and using the Shake API
    COMP4126›Using property lists for data persistence and creating multi-section tables
    Mobile Application Development 2Topic 20 of 38

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

    4 minread
    620words
    Beginnerlevel

    📱 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 load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time4 min
      Word count620
      Code examples0
      DifficultyBeginner