Skip to content

Instantly share code, notes, and snippets.

@mikeabdullah
Created September 12, 2012 11:15
Show Gist options
  • Save mikeabdullah/3706001 to your computer and use it in GitHub Desktop.
Save mikeabdullah/3706001 to your computer and use it in GitHub Desktop.
Pre-flight saving a Core Data binary store
NSNumber *writable;
if ([storeURL getResourceValue:&writable forKey:NSURLIsWritableKey error:outError])
{
if ([writable boolValue])
{
return [context save:outError];
}
else if (outError)
{
// Generic error. NSError takes care of supplying a nice generic message to go with it
*outError = [NSError errorWithDomain:NSCocoaErrorDomain
code:NSFileWriteNoPermissionError
userInfo:nil];
}
}
return NO;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment