How to Save Data on XCode for the iPhone

The iPhone Xcode development platform includes the necessary classes to save data on the iPhone system. You save the data in a text file on the phone, and you can later import the data from the file to load the variables and data into the system when the app restarts. The text file format in the iPhone SDK is the "PLIST" file extension.

Instructions

    • 1

      Open your Xcode editor on your computer and the iPhone app project you want to edit. Double-click the file you want to edit and store the data file.

    • 2

      Create a function method for the the save feature in your app. The following code creates a function, and you place your code within the function brackets:

      - (NSString *) myFileSave
      {

      }

    • 3

      Set up the save path for your app. The iPhone operating system handles the location to save the file, but you must create a variable. Add the following code to your function:

      NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

    • 4

      Save the file to the system. The following code stores a file named "myfile.plist" to the system:

      return [[path objectAtIndex:0] stringByAppendingPathComponent:@"myfile.plist"]

Related Searches:

References

Comments

Related Ads

Featured