func loadMe() -> Void {
println(me.initUrl());
let url:NSURL = NSURL(string:me.initUrl())
let request:NSURLRequest = NSURLRequest(URL:url)
let queue:NSOperationQueue = NSOperationQueue()
NSURLConnection.sendAsynchronousRequest(request, queue:queue, completionHandler:{response, data, error in
if data {
var jerr:NSError?
var json:NSDictionary = NSJSONSerialization.JSONObjectWithData(data, options:NSJSONReadingOptions.MutableContainers, error:&jerr) as NSDictionary
if !jerr {
println(json.description)
let time:String = json.valueForKey("time") as String
println(time)
// self.me.setDictionary(json)
}
}
})
}
The code above works fine up to the point where i want to assign a value from an NSDictionary to a variable.
let time:String = json.valueForKey("time") as String
is followed by EXC_BAD_INSTRUCTION(code=EXC_I386_INVOP,subcode=0x0) but
println(json.description)
prints out a valid NSDictionary. Does anybody know a solution to this problem?