source: branches/CoreData/SapphireFrappliance/MetaData/SapphireMObjects/SapphireGenre.m @ 573

Revision 573, 1.1 KB checked in by gbooker, 7 years ago (diff)

Some accellerations

Line 
1#import "SapphireGenre.h"
2#import "CoreDataSupportFunctions.h"
3
4@implementation SapphireGenre
5
6+ (SapphireGenre *)genre:(NSString *)genre inContext:(NSManagedObjectContext *)moc
7{
8        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name == %@", genre];
9        NSArray *array = doFetchRequest(SapphireGenreName, moc, predicate);
10       
11        if([array count])
12                return [array objectAtIndex:0];
13       
14        return nil;
15}
16       
17+ (SapphireGenre *)createGenre:(NSString *)genre inContext:(NSManagedObjectContext *)moc
18{
19        SapphireGenre *ret = [SapphireGenre genre:genre inContext:moc];
20        if(ret != nil)
21                return ret;
22       
23        ret = [NSEntityDescription insertNewObjectForEntityForName:SapphireGenreName inManagedObjectContext:moc];
24        ret.name = genre;
25        return ret;
26}
27
28- (NSString *)filesValue
29{
30        return @"movies";
31}
32
33- (NSString *)fileNameValue
34{
35        return @"title";
36}
37
38- (NSString *)metaFilesValue;
39{
40        return @"movies.@distinctUnionOfSets.files";
41}
42
43- (NSArray *)defaultFileSort:(NSArray *)files
44{
45        return [files sortedArrayUsingSelector:@selector(titleCompare:)];
46}
47
48- (NSString *)path
49{
50        return [super.path stringByAppendingPathComponent:self.name];
51}
52
53@end
Note: See TracBrowser for help on using the repository browser.