I followed the same tutorial and received the same error message. I found out what the problem is.
In my case, the file could not be created because the storeURL path was incorrect and was pointing to a folder that did not exist.
In my helper method [self applicationDocumentDirectory] (which you did not specify in your question), I typed an example code in the same way as in the tutorial:
- (NSString *) applicationDocumentsDirectory { return [NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES) lastObject]; }
who created the URL file:///Users/xxxxxx/Library/Application%20Support/iPhone%20Simulator/7.0.3/Applications/A6FDD8DB-475B-4C9B-B995-28CCE068DF82/ Library / Documentation /
There is a typo of stupid code that generates an invalid path. You see?
It lists the NSDocumentationDirectory for the input parameter NSSearchPathDirectory, instead it should be NSDocumentDirectory.
The correct code and URL:
- (NSString *) applicationDocumentsDirectory { return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject; }
URL: file:///Users/xxxxxx/Library/Application%20Support/iPhone%20Simulator/7.0.3/Applications/A6FDD8DB-475B-4C9B-B995-28CCE068DF82/ Documents /
source share