Closed yusuftor closed 7 years ago
Hey @yusuftor ! 😄
I would definitely parse out the JSON into model objects. It sounds like you're just using raw JSON? That's probably not the best practice. 😅
The flow should be something like this:
IGListDiffable
)-objects(for:)
SectionController
, you'll receive this model in -didUpdateToObject:
@jessesquires Thanks a lot for your help and explaining. But would it be difficult for you, with all my respect, to show us a legit example with a simple json example and how can we make a model that conforms to IGListDiffable
?
Again, thanks a lot 😃
@kwstasna Check out the latest demo that we added for an example custom model that conforms to IGListDiffable
:
For doing JSON-to-Person
and diffing, imagine something like:
let response: [ [String: Any] ] = // something from the web
var people = [Person]()
for json in response {
if let pk = json["pk"] as? Int,
let name = json["name"] as? String {
people.append(Person(pk: pk, name: name))
}
}
let result = IGListDiffable(oldPeople, people, .equality)
// do something w/ the diff
If people would find it handy, I'm more than happy to create a JSON example which takes a local json file parses it into objects and displays a mixed data view?
Feel free to assign this to me!
@rnystrom ok I think i got it now. @Sherlouk I would be glad just to know that I'm doing it right 😄
💯 🎉
Hi, Firstly, I think this IGListKit is awesome and so useful!
This is more of a question than an issue, but I have JSON data returned from my servers that I want to populate my list with. Usually I would use SwiftyJSON to handle the data, and everytime
-cellForItemAt
is called, use something likedata[indexPath.row]["text"].stringValue
to retrieve the right part of the data and input it into the cell. However, I'm trying to figure out how to make this data work with IGListKit. As far as I can work out, I need to be able to some how separate each JSON object and combine it into an array that implements IGListDiffable to be returned in-objects(for:)
.Would it be possible to provide me with some pointers, and possibly give an example of downloading and parsing JSON data from the web in the IGListKit example app? I think it would be super useful as I can see most people using this framework with data downloaded from online!
Thanks!