Question

I am doing one application for iphone.In that i am creating .txt files and storing my information in that files.WHenever app open again i got the information from that files.Here is the code for creating the .txt files

     NSString* filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
     NSString* fileName = @"user_data.txt";
     NSString* fileAtPath = [filePath stringByAppendingPathComponent:fileName];

    if (![[NSFileManager defaultManager] fileExistsAtPath:fileAtPath]) {
    [[NSFileManager defaultManager] createFileAtPath:fileAtPath contents:nil attributes:nil];
     }

And in some links i found if we save any data in DocumentDirectory then app will be reject by apple,because that data is upload to iCloud.So please tell me is it true or not.If yes then how can i store my files.

Was it helpful?

Solution

You can't save any data before the app Launches for the first time.i.e. If user user just install the app & not open the app then Document Directory must be blank.

If you launches the app then you can save data as much big as memory is free in the device.

If you store files in Documents, they will be backed up to iCloud automatically. If you don't want that, the easiest way is to just store them somewhere else. Library/Caches is a good choice. If you really MUST store in Documents but you want to disable iCloud backup you can use the technique outlined here:

https://developer.apple.com/library/ios/#qa/qa1719/_index.html

OTHER TIPS

Please check here, You need to set "do not back up" attribute, or another solutions is that you can save files in /Library/Caches to avoid having it backed up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top