ios - Convert NSString representing an array of arrays of numbers to NSArray -


i receiving string in request; string list of pairs of numbers, grouped square brackets. (the list represents polygons display inside app.)

i need convert nsarray , parse numbers coordinates.

the received string is

[[[53.502483, -113.420593], [53.503429, -113.421527], [53.503491, -113.421673], [53.503002, -113.42164], [53.502719, -113.421426], [53.502483, -113.420593]]] 

all examples i've found convert single list in text nsarray. couldn't find there multiple arrays in string.

the string looks valid json, so...

nserror *error; nsdata *data = [string datausingencoding:nsutf8stringencoding]; nsarray *array = [nsjsonserialization jsonobjectwithdata:data options:nil error:&error]; 

will give array, provided string contains input. if it's coming web request, can save step , convert request's nsdata directly.


Comments