Reputation: 361
How do I show the following code in table view using swift 2 swiftyJSON
I am new so full guide would be appreciated
I have already worked of other json open source projects but without swiftyJSON
{"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}
Upvotes: 0
Views: 131
Reputation: 111
First of all, just read the SwiftJSON usage part, this is the right place to start.
Just some tips shortly:
First you need to get your json data from someone (in this case, this will come from a get request, and stored in NSData?)
let json = JSON(data: data!)
var names = [String]()
let count = json["employees"].count
for var i = 0; i < count; ++i
{ let name = json["employees"][i]["firstName"].stringValue self.names.append(name)
}
After that you should simple use this array in UITableView delegate methods.
Upvotes: 2