Answer the question
In order to leave comments, you need to log in
Handling JSON data in Swift?
I decided to process the JSON data received from the server into an array, but it gives an error:
func parseJSON(data: NSData) -> NSDictionary{
let jsonResult: NSDictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers) as! NSDictionary
return jsonResult;
}
Call can throw, but it is not marked with 'try' and the error is not handled
Variable 'boardsDictionary' used before being initialized
func parseJSON(inputData: NSData) -> NSDictionary{
var boardsDictionary: NSDictionary;
do {
try boardsDictionary = NSJSONSerialization.JSONObjectWithData(inputData, options: NSJSONReadingOptions.MutableContainers) as! NSDictionary
} catch {}
return boardsDictionary;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question