Saving data to disk on iOS

| | August 7, 2015

My application got rejected for following reason:

App Review
1.0 Binary Rejected August 5, 2015
2.23 Details On launch and content download, your app stores 9.51 MB on the user's iCloud, which does not comply with the iOS Data Storage

As much as I understand (correct me if I’m wrong) it’s because I save too much on NSUserDefaults(I don’t save anywhere else).

So here’s my question: Is there a quick, easy way to save data locally(similiar to NSUserDefaults but not end up saving on “user’s iCloud”, instead of using CoreData?

One Response to “Saving data to disk on iOS”

  1. Yes, there is a way.
    You can store your data using NSKeyedArchiver and NSKeyedUnarchiver.
    NSKeyedArchiver is used to save your data. An example:

    [NSKeyedArchiver archiveRootObject:counters toFile:filePath];
    

    Extension of the filePath should be .plist; counters in this case is an array.

    NSKeyedUnarchiver is used to load your data. An example:

    if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
        counters = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
    }
    

    If you want to store your custom class, you need to implement NSCoding protocol.

Leave a Reply