Created
October 12, 2013 23:35
-
-
Save westonplatter/6956171 to your computer and use it in GitHub Desktop.
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
| // some ObjectiveC class implementation | |
| // manages some models within a CoreData ManagedObjectContext | |
| // | |
| // example for getting first object within a NSSet by object's "start" attribute | |
| // | |
| -(Asset *)getFirstAssetByStart | |
| { | |
| Asset *asset = nil; | |
| NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"start" ascending:YES]; | |
| NSArray* sortDescriptors = [[NSArray alloc] initWithObjects: sortDescriptor, nil]; | |
| NSArray *assetsOrderedByStart = [[_package.assets allObjects] sortedArrayUsingDescriptors:sortDescriptors]; | |
| asset = [assetsOrderedByStart firstObject]; | |
| return asset; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment