fs_tigre
fs_tigre

Reputation: 10738

What are the options when reading and writing information in iOS

Can someone be so kind and explain the options to read and write information in iOS? What I’m looking for is not explanation on how to read and write simply the options available when saving in iOS.

The main reason for this question is because I’m currently practicing with a small app I created, the app does some calculations and I would like to be able to save the result locally for later use.

  1. What are the options when saving a simple NSString locally in iOS? Is this even possible?

  2. If the above is possible, where are these local files saved?

  3. How much can you save locally before you need a database?

  4. What classes/methods should I be looking into (the only one I found so far is NSData)?

Again what I’m looking for with this question is understand what the options are when reading and writing information in iOS.

Thanks a lot.

Upvotes: 0

Views: 103

Answers (1)

Radu
Radu

Reputation: 3494

There are several options for saving data in iOS application:

NSUserDefaults, recommended for primitive types(string, bool, etc) or NSDictionary

NSFileManager, - for reading, writing, copying, moving, renaming files in your app

NSCoding, - for storing objects that comply to the nscoding protocol

CoreData, - and of course core data framework for complex data models

If the above is possible, where are these local files saved?

NSUserDefaults is a class but i think it saves in a plist file in the app bundle(i might be wrong about this one);

NSFileManager - saves the files on disc in one of it's standard Directories like the Document directory

NSCoding - on disc similar to the NSFileManager,

CoreData saves it in a sqllite database.

How much can you save locally before you need a database?

Depends on the device but since you don't plan to save 1 G files on the device i think you should think in therms of architecture - how complex is the data model and for what pourpes will you use it

What classes/methods should I be looking into (the only one I found so far is NSData)? NSData hase a few methods about how to convert it into a file and save it to disc, these are convenient methods, but for the raw file manipulation look at the links above.

Upvotes: 1

Related Questions