Skip to content

Instantly share code, notes, and snippets.

@davidpdrsn
Created July 13, 2014 21:13
Show Gist options
  • Save davidpdrsn/6f682877768a076196a7 to your computer and use it in GitHub Desktop.
Save davidpdrsn/6f682877768a076196a7 to your computer and use it in GitHub Desktop.
Core Data error
#pragma mark - validation
- (BOOL)validateForInsert:(NSError *__autoreleasing *)error {
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
[userInfo setObject:@"Cannot add more than 10 moves" forKey:NSLocalizedFailureReasonErrorKey];
[userInfo setObject:self forKey:NSValidationObjectErrorKey];
NSError *tooManyMovesError = [NSError errorWithDomain:@"TenMovesDomain" code:NSManagedObjectValidationError userInfo:userInfo];
if (*error == nil) {
*error = tooManyMovesError;
} else {
*error = [NSError errorFromOriginalError:*error error:tooManyMovesError];
}
return NO;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment