Thursday 15 March 2012

ios - XCode 6.1 possible indexing bug? -



ios - XCode 6.1 possible indexing bug? -

i trying create complex array in playground way below:

import uikit allow demodata = [ [ "name":"mr bean", "number": "012345678", "address": "4 d. street", "dob": "21-9-1970", "gender": "male", "docs": [ "alerts":["jt_alert_1.jpg", "jt_alert_2.jpg"], "notes":["jt_notes_1.png", "jt_notes_2.jpg", "jt_notes_3.jpg", "jt_notes_4.jpg"], "correspondence": [], "investigations": [], "operationsheets": [], "treatmentcharts": [] ] ], [ "name":"jenny thomas", "number": "012345679", "address": "5 d. street", "dob": "22-9-1970", "gender": "female", "docs": [ "alerts":[], "notes":[], "correspondence": [], "investigations": [], "operationsheets": [], "treatmentcharts": [] ] ] ]; allow notes: anyobject? = demodata[0]["docs"]!["notes"]! allow notepics = notes array<string> notepics[0]

the spinning wheel @ bottom right corner keeps spinning ever. when created new swift project, same code froze while xcode indexing

does else had same problem? if yes, solutions?

thanks in advance

your info complex making hard swift figure out doing. give compiler hint construction of demodata:

let demodata:[[string:anyobject]] = [ ...

and good.

you might want more explicit expect find while unpacking structure:

if allow docdict = demodata[0]["docs"] as? [string:anyobject] { if allow notepics = docdict["notes"] as? [string] { println(notepics[0]) } }

the optional binding (if let) combined conditional casts (as?) provides safety program. if wrong 1 of keys, or if wrong info type of value, never come in inner block. if utilize force unwrapping (!), programme crash if key not in dictionary. likewise, if cast value (with as) type not, programme crash.

ios xcode swift

No comments:

Post a Comment