I get JSON data as a result of NSURLSession.sharedSession().dataTaskWithRequest
and deserialize it to AnyObject
:
var error: NSError?
let jsonObject: AnyObject? = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.AllowFragments, error: &error)
I want to pass it to a completion handler for parsing jsonObject
into structured data.
Question: will jsonObject
be passed by reference or deep-copied? The question arises since Array
and Dictionary
that JSON consists of are value-type in Swift.
I found this answer to related question that says that objects inside Foundation are indeed NSArray
and NSDictionary
, i.e. reference types. Is it the same with JSON data?