-
-
Save anonymous/a167148a8a6d169292ff to your computer and use it in GitHub Desktop.
Swift 1.2 : Json Array Parsing
This file contains 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
let url=NSURL(string:"http://dl-8.one2up.com/onetwo/content/2015/6/15/9c3b51249fbbe20ca9d841401e276d97.php") | |
let allContactsData=NSData(contentsOfURL:url!) | |
var allContacts: AnyObject! = NSJSONSerialization.JSONObjectWithData(allContactsData!, options: NSJSONReadingOptions(0), error: nil) | |
if let json = allContacts as? Array<AnyObject> { | |
print("JSON: \(json)") | |
for index in 0...json.count-1 { | |
let contact : AnyObject? = json[index] | |
let collection = contact! as! Dictionary<String, AnyObject> | |
let name : AnyObject? = collection["AnimeName"] | |
let cont : AnyObject? = collection["Episodes"] | |
names.append(name as! String) | |
episodes.append(cont as! String) | |
} | |
} | |
println(names) | |
println(episodes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment