ios - How to increment a Json Object in objective-c -


how increment array of json?

i have array, "jsonobjects" loads json webservice:

            arrbusca = [jsonobjects objectforkey:key]; 

if print array, results this:

2013-03-26 16:50:48.167 teste[6645:907] array 1: (     {     idmarca = 118;     idtipo = 1;     marca = "";     ordem = 9999;     tipo = carro;     },     {     idmarca = 60;     idtipo = 1;     marca = " -";     ordem = 2;     tipo = carro;     },     {     idmarca = 117;     idtipo = 1;     marca = "---";     ordem = 2;     tipo = carro;    } } 

and want increment array, try:

    marcas *myperson = [[marcas alloc] init];     myperson.marca = [nsstring stringwithformat:@"fiat %d", i];     myperson.idmarca = [nsstring stringwithformat:@"%d", i];     [arrbusca addobject:myperson]; 

but result is:

2013-03-26 16:50:48.167 teste[6645:907] array 1: (     {     idmarca = 118;     idtipo = 1;     marca = "";     ordem = 9999;     tipo = carro;     },     {     idmarca = 60;     idtipo = 1;     marca = " -";     ordem = 2;     tipo = carro;     },     {     idmarca = 117;     idtipo = 1;     marca = "---";     ordem = 2;     tipo = carro;    }, "<marcas: 0x1fd807e0>", "<marcas: 0x1fd89e40>", "<marcas: 0x1fd80c90>", "<marcas: 0x1fd8a1b0>", "<marcas: 0x1fd8ada0>", "<marcas: 0x1fd89cb0>", } 

anyone knows how increment jsonobject array?

you need provide nscoder methods archive , unarchive "marcas" objects.

right now, when add objects "arrbusca" nsmutablearray (it is mutable, right?), they're being added "marcas" objects , not raw non-marcas objects decoded json).


Comments