R
R
Riedel872016-02-14 08:33:56
iOS
Riedel87, 2016-02-14 08:33:56

How to use property list ios to insert into custom TableView in swift?

Hello everyone) I found a video on how to draw a custom TableView, but I need to load data from the property list (.plist file) into the cells. Does anyone have examples of this? Something has already broken his head and Google has revised everything.
It seems like you need to turn the plist file into a dictionary, and then work like a dictionary and push the data into the cells, I found similar videos somewhere, but I can’t understand the logic to the end (
But it should look like in the attached picture.
Maybe someone directly has a similar project to actually see?
a16cc041e1f5414c842987733381f889.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
An, 2016-02-14
@Riedel87

Let's go in order
1) You need to declare a model. Let it be a certain class inherited from NSObject (here you will have to abandon pure swift for ease of interaction with plist)
Describe the properties of this message. At a glance, you have
let time: NSDate
let text: String
let senderName: String
let senderImage: NSURL Something else
is possible
2) implement methods for deserializing data from plist (google for NSKeyedUnarchiver, plist, swift tags). N / B if you choose the data format, then abandon plist in favor of json. It is easier to work with it, a bunch of ready-made libraries, if you decide to interact with the server, you will get a solution out of the box.
3) implement a UITableView inheritor class with similar properties, but instead of string/url uilabel/uiimageview. + create custom layout for this cell in xib/storyboard. Google the custom uitableview layout subclass tags
4) When loading the controller (viewDidLoad, for example), load the data into the array from point one. Not very beautiful, but just
Next, shove this data into the cells in the cellForRowAtIndexPath method.
Again, see the examples in google from point 3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question