Reputation: 287
First post on StackOverflow, after extensively using it for a long time.
I'm building a small app (just to lear swift), and I have troubles with making some data persistent. I use NSCoding to achieve that. The problem is that when saving, the function NSKeyedArchiver.archiveRootObject()
return true
(so apparently it worked), but when, later, I try to retrieve these saved informations, the result of NSKeyedUnarchiver.unarchiveObjectWithFile()
is nil
.
Without posting all my code, I was just wondering if it were possible to explore the file in which persistent data are stored during a debug session. That would allow me to check whether I have a problem with the saving or the loading part of the process, and see if the data are indeed stored in the right file.
Thanks,
Lb
Upvotes: 3
Views: 493
Reputation: 38162
Per Apple Documentation, you get a nil
with unarchiveObjectWithFile
when there is no file at the mentioned path. I would advise to check your file path where you are archiving and saving your object.
As for the debugging, follow this:
NSKeyedArchiver.archiveRootObject(myObject, toFile: filePath)
print filePath
.terminal
app and execute open <filePath>
command to open the file path where data is being saved.Upvotes: 1