반응형
[ios/tutorial] Core Data - Fetching Objects
-
NSFetchRequest 를 이용해서 존재하는 data 를 fetch 해올 수 있다.
Fetching NSManagedObject Instances
-
NSManagedObjectContext *moc = …;
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEnityName:@“Employee”];
NSError *error = nil;
NSArray* result = [moc executeFetchRequest:request error:&error];
if (!result){
DLog(@“Error fetching employee objects: %@\n%@“, [error localizedDescription], [error userInfo]);
abort();
}
Fetching Results
-
NSPredicate 를 이용하면 조건을 걸어서 fetch 를 할 수 있다.
NSString *firstName = @“Trevor”;
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@“firstName == %@“, firstName]];
반응형
'프로그래밍 놀이터 > iOS' 카테고리의 다른 글
[ios/tutorial] Core Data - Creating and Saving Managed Objects (0) | 2017.11.06 |
---|---|
[ios/tutorial] Core Data - Creating and Modifying Custom Managed Objects (0) | 2017.11.05 |
[ios/tutorial] Core Data - Initializing the Core Data Stack (0) | 2017.11.03 |
[ios/tutorial] Core Data - Creating a Managed Object Model (0) | 2017.11.02 |
[ios] Nullable & NonNull annotation (0) | 2017.10.30 |
댓글