June 2015
Intermediate to advanced
192 pages
4h 8m
English
The same
NSJSONSerialization class is available in Swift, Apple's new language for iOS development.
Here's an example of how to invoke the JSONObjectWithData method of NSJSONSerialization in Swift:
import Foundation var error: NSError? Let json: NSData = /* the JSON to parse */ let data = NSJSONSerialization.JSONObjectWithData(json, options: nil, error: &error);
Method invocations in Swift look like function invocations, with the arguments passed as (optionally named) comma-delimited arguments, similar to how they're invoked in C++ or Java. The arguments to JSONObjectWithData are identical to the method arguments in the Objective-C version.
Read now
Unlock full access