Write JSON from textfields to a file for iOS 5+ -


i'm new ios programming, , having trouble finding beginner-level explanation of how write contents of multiple text fields local json file in such way keep organized.

for example, user form have name, address, email, etc., need put customer object.

the purpose of save data several forms, , pass data database.

you'll need convert text fields dictionary (or dictionary of dictionaries). once have done, convert dictionary json data , save that:

nserror *error = nil; nsdata *jsondata = [nsjsonserialization datawithjsonobject:myjsondict options:0 error:&error];  if (jsondata != nil) {     nsstring *jsonfilepath = ...;     bool status = [jsondata writetofile:jsonfilepath atomically:yes];      if (!status) {         nslog(@"oh no!");     } } else {     nslog(@"my json wasn't valid: %@", error); } 

you need create path , check status.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -