forked from pmougin/F-Script
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathArrayRepFetchRequest.m
55 lines (43 loc) · 1.4 KB
/
ArrayRepFetchRequest.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* ArrayRepFetchRequest.m Copyright (c) 2004-2009 Philippe Mougin. */
/* This software is open source. See the license. */
#import "ArrayRepFetchRequest.h"
#import "ArrayRepId.h"
#import "FSArray.h"
@implementation ArrayRepFetchRequest
+ (ArrayRepFetchRequest *) arrayRepFetchRequestWithFetchRequest:(NSFetchRequest *)theFetchRequest objectContext:(NSManagedObjectContext *)theObjectContext
{
return [[[self alloc] initWithFetchRequest:theFetchRequest objectContext:theObjectContext] autorelease];
}
- (ArrayRepId *) asArrayRepId
{
NSError *error = nil;
NSArray *objects;
objects = [objectContext executeFetchRequest:fetchRequest error:&error];
if (error)
{
NSLog(@"Error when fetching an ArrayRepFetchRequest: %@", error);
objects = [NSArray array];
}
return [ArrayRepId arrayWithArray:objects];
}
- (id)copyWithZone:(NSZone *)zone
{
return [[ArrayRepFetchRequest allocWithZone:zone] initWithFetchRequest:fetchRequest objectContext:objectContext];
}
- (void)dealloc
{
[fetchRequest release];
[objectContext release];
[super dealloc];
}
- (id)initWithFetchRequest:(NSFetchRequest *)theFetchRequest objectContext:(NSManagedObjectContext *)theObjectContext
{
if ((self = [super init]))
{
fetchRequest = [theFetchRequest retain];
objectContext = [theObjectContext retain];
}
return self;
}
- (enum ArrayRepType)repType {return FETCH_REQUEST;}
@end