I have an NSMutableDictionary, and I wrote it using
[stuff writeToFile:@"TEST" atomically:YES];
How can I retrieve it in the future?
Also, what would happen if I decide to replace my iPhone 4 with the 4S? Can my piece of written data be transferred?
You can use NSUserDefaults to store your Dictionary like this:
And later you can retrieve it like this:
Also nothing will happen if you use the same code with an iPhone 4 or an iPhone 4S.
A Swift solution
First you need to define a path to write to. If you use
[stuff writeToFile:@"TEST" atomically:YES];
in the iPhone simulator it will write a file called TEST in your home directory of your Mac. Use this code to save to the Documents folder in the simulator and on the iPhoneHere is the code you need to read and write files.
I think you want something like:
You do need to obtain the correct path to store and retrieve your file, along the lines of this routine: