ios - Swift - NSDictionary optional value crash -
let dataarray = jsondict["results"] nsarray; item in dataarray { allow obj = item nsdictionary var destination:string = obj["destination"] string! println(destination) }
above have nsarray looping through obtained parsing json file.
my problem is, can see output println
successful application crashes whilst looping through. i'm pretty sure because of how i'm handling nsdictionary optional values i'm not sure how around it.
do need check optional value or along lines before printing it?
any ideas?
let dataarray = jsondict["results"] nsarray; item in dataarray { allow obj = item nsdictionary if allow foundname = obj["destination"] { println("name: \(foundname)") } }
checking optional value before printing fixed problem.
ios xcode swift xcode6
No comments:
Post a Comment