0

Created array of dictionary having buttons.

-created UITableviewcell.xib and .swift -created ib -linked ib -linked dataSource and Delegates need help further to read my plist data and show it into tableViewCell

1 Answers1

0

Use Decodable, it's very simple

struct Section : Decodable {
    let title, icon : String
}

If the file is in the bundle, read it as Data and decode it

let url = Bundle.main.url(forResource: "sections", withExtension: "plist")!
do {
    let data = try Data(contentsOf: url)
    let result = try PropertyListDecoder().decode([Section].self, from: data)
} catch { print(error) }

result will contain an array of Section items

vadian
  • 274,689
  • 30
  • 353
  • 361
  • Thank yu @vadian Sir, as always you helped me. i now have to show this array of Dictionary of Button into each Cell. Guide me further Please? Also include a must to do list in your answers related to the specific topics for beginners sir, it will help us alot and learn and understand more. – MALIKK HABIB UR REHMAN Jan 09 '19 at 10:53
  • cell.lblimage.image = set.title // can not convert of type string into UIImage – MALIKK HABIB UR REHMAN Jan 09 '19 at 10:55
  • A string is not an image. To show an image it must be in the application bundle and you can write `cell.lblimage.image = UIImage(named: set.title)` (more likely `... named: set.icon`) – vadian Jan 09 '19 at 10:59