Created
November 30, 2011 07:37
-
-
Save yasirmturk/1408346 to your computer and use it in GitHub Desktop.
A generic core data function to check whether a record already exists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Useful function to check whether a record already exists | |
*/ | |
-(BOOL)doesRecordExistForEntity:(NSString *)entity fieldToCheck:(NSString *)fieldName valueToMatch:(id)val | |
{ | |
NSPredicate *pred = [NSPredicate predicateWithFormat:@"(%K = %@)", fieldName, val]; | |
//NSLog(@"(P: %@)", [pred predicateFormat]); | |
NSArray *arr = [self queryDBForEntity:entity predicate:pred sortByField:fieldName]; | |
//NSLog(@"%@", arr); | |
return ([arr count] > 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment