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

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -