forked from Xcode-Snippets/Objective-C
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cdfetch.m
21 lines (17 loc) · 806 Bytes
/
cdfetch.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Core Data Fetch
// Simple Core Data Fetch with Predicate & Sort Descriptor
//
// IDECodeSnippetCompletionScopes: [All]
// IDECodeSnippetIdentifier: FA449175-4AEB-4617-883B-E242C6FFD300
// IDECodeSnippetLanguage: Xcode.SourceCodeLanguage.Objective-C
// IDECodeSnippetUserSnippet: 1
// IDECodeSnippetVersion: 2
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:<#entityName#>];
fetchRequest.predicate = [NSPredicate predicateWithFormat:<#predicateFormat#>];
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:<#key#> ascending:<#isAscending#> selector:<#selector#>];
fetchRequest.sortDescriptors = @[sortDescriptor];
NSError *error;
NSArray *results = [<#context#> executeFetchRequest:fetchRequest error:&error];
if (error) {
NSLog(@"%@", error);
}