I\'ve tried to build up a document-based Cocoa app and when I tried to parse JSON in readFromData: ofType: error:
method, I got an error: fatal error: unexpec
Then your funciton should be:
override func readFromData(data: NSData?, ofType typeName: String?, error outError: NSErrorPointer) -> Bool {
if let loadedDictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.AllowFragments, error: outError) as? NSDictionary {
return true
} else {
return false
}
}
Now this function:
ourError
should error occurFYI I happened to write a JSON handler, too.
Which includes NSJSONSerialization.JSONObjectWithData
.