I have the problem, that I get a fatal error: unexpectedly found nil while unwrapping an Optional value.
I send a http request to my server. Like this
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {(response, data, error) in
if error == nil {
var datastring:String = NSString(data:data, encoding:NSUTF8StringEncoding)!
// println(datastring)
if (data != nil) {
var json=NSJSONSerialization.JSONObjectWithData(data!, options: nil, error: &self.err) as NSDictionary
println(json)
if (error != nil) {
println(self.err?.localizedDescription)
} else {
//do something here with json
}
}
} else {
println(error.localizedDescription)
}
and get this json file:
{ "_id" : { "$oid" : "54feffe1412807551c90eaa2"} , "loc" : [ 35.09 , 12.01]},
{ "_id" : { "$oid" : "54ff0b62412807551c90eaa4"} , "loc" : [ 43.98 , 12.34]}
If I have only one file it works. But with two files I get the fatal error.