ios - How to create a dictionary with 2 arrays inside? -
i want create dictionary next structure, sending via alamofire json server:
{ "user": { "firstname": "fname", "lastname": null, "img": null, "books": [ { "id": 1 }, { "id": 2 } ] }, "locale": "en", "gender": "male" } for structure of json, i've tried next:
let parameters: [[string: [string: string]], [string: string]] but there lot closures, confused it. can me creating structure?
the collection types in swift standard library support homogenous collections, i.e. elements in collection must have same type. cannot declare array first element of type [string: [string: string]] , second element of type [string: string] if wanted.
this works:
let parameters = [ "user": [ "firstname": "fname", "lastname": nsnull(), "img": nsnull(), "books": [ [ "id": 1], [ "id": 2] ] ], "locale": "en", "gender": "male" ] the type of parameters [string: nsobject] nsobject superclass of values in dictionary. note use of nsnull model null values, nsjsonserialization expects.
Comments
Post a Comment