Created
April 18, 2017 09:49
-
-
Save YonathanMeguira/7b5198a34ee8dc31a3172758bcbbd6f4 to your computer and use it in GitHub Desktop.
swift=> casting dictionary? to struct
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct dataStruct { | |
var address = String() | |
var age = Int() | |
var balance = String() | |
var company = String() | |
var email = String() | |
var gender = String() | |
var name = String() | |
var phone = String() | |
var picture = String() | |
} | |
@IBOutlet weak var dataTable: UITableView! | |
var data = [dataStruct]() | |
func loadData() { | |
Alamofire.request("https://api.myjson.com/bins/62za3").responseJSON { response in | |
if let JSON = response.result.value { | |
for res in (JSON as! Array<Any>){ | |
data.append(res.name as String) | |
} | |
} | |
self.dataTable.reloadData() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment