How to convert a JavaScript array to a NSArray in Objective-C/iOS? -
How to convert a JavaScript array to a NSArray in Objective-C/iOS? -
what's best way convert javascript array (saved in nsstring) format:
["hello", "world"]
in nsarray?
thanks
try this!
nsstring * jsonstring = @"[\"hello\",\"world\"]"; nserror * serializationerror = nil; nsarray * array = [nsjsonserialization jsonobjectwithdata:[jsonstring datausingencoding:nsutf8stringencoding] options:nsjsonreadingallowfragments error:&serializationerror]; nslog(@"nsarray - %@ \n error - %@", array, serializationerror.localizeddescription);
log:
nsarray - ( hello, world ) error - (null)
javascript ios objective-c arrays
Comments
Post a Comment