forked from rentzsch/mogenerator
/
_HumanMO.m
182 lines (120 loc) · 4.46 KB
/
_HumanMO.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// DO NOT EDIT. This file is machine-generated and constantly overwritten.
// Make changes to HumanMO.m instead.
#import "_HumanMO.h"
@implementation HumanMOID
@end
@implementation _HumanMO
+ (id)insertInManagedObjectContext:(NSManagedObjectContext*)moc_ {
NSParameterAssert(moc_);
return [NSEntityDescription insertNewObjectForEntityForName:@"Human" inManagedObjectContext:moc_];
}
+ (NSString*)entityName {
return @"Human";
}
+ (NSEntityDescription*)entityInManagedObjectContext:(NSManagedObjectContext*)moc_ {
NSParameterAssert(moc_);
return [NSEntityDescription entityForName:@"Human" inManagedObjectContext:moc_];
}
- (HumanMOID*)objectID {
return (HumanMOID*)[super objectID];
}
+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key];
return keyPaths;
}
@dynamic hairColorStorage;
@dynamic humanName;
@dynamic meaninglessRelationship;
+ (NSArray*)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ {
NSError *error = nil;
NSArray *result = [self fetchByHumanName:moc_ humanName:humanName_ error:&error];
if (error) {
#if TARGET_OS_IPHONE
NSLog(@"error: %@", error);
#else
[NSApp presentError:error];
#endif
}
return result;
}
+ (NSArray*)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ error:(NSError**)error_ {
NSParameterAssert(moc_);
NSError *error = nil;
NSManagedObjectModel *model = [[moc_ persistentStoreCoordinator] managedObjectModel];
NSDictionary *substitutionVariables = [NSDictionary dictionaryWithObjectsAndKeys:
humanName_, @"humanName",
nil];
NSFetchRequest *fetchRequest = [model fetchRequestFromTemplateWithName:@"byHumanName"
substitutionVariables:substitutionVariables];
NSAssert(fetchRequest, @"Can't find fetch request named \"byHumanName\".");
NSArray *result = [moc_ executeFetchRequest:fetchRequest error:&error];
if (error_) *error_ = error;
return result;
}
+ (id)fetchOneByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ {
NSError *error = nil;
id result = [self fetchOneByHumanName:moc_ humanName:humanName_ error:&error];
if (error) {
#if TARGET_OS_IPHONE
NSLog(@"error: %@", error);
#else
[NSApp presentError:error];
#endif
}
return result;
}
+ (id)fetchOneByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ error:(NSError**)error_ {
NSParameterAssert(moc_);
NSError *error = nil;
NSManagedObjectModel *model = [[moc_ persistentStoreCoordinator] managedObjectModel];
NSDictionary *substitutionVariables = [NSDictionary dictionaryWithObjectsAndKeys:
humanName_, @"humanName",
nil];
NSFetchRequest *fetchRequest = [model fetchRequestFromTemplateWithName:@"oneByHumanName"
substitutionVariables:substitutionVariables];
NSAssert(fetchRequest, @"Can't find fetch request named \"oneByHumanName\".");
id result = nil;
NSArray *results = [moc_ executeFetchRequest:fetchRequest error:&error];
if (!error) {
switch ([results count]) {
case 0:
// Nothing found matching the fetch request. That's cool, though: we'll just return nil.
break;
case 1:
result = [results objectAtIndex:0];
break;
default:
NSLog(@"WARN fetch request oneByHumanName: 0 or 1 objects expected, %u found (substitutionVariables:%@, results:%@)",
[results count],
substitutionVariables,
results);
}
}
if (error_) *error_ = error;
return result;
}
+ (NSArray*)fetchAllHumans:(NSManagedObjectContext*)moc_ {
NSError *error = nil;
NSArray *result = [self fetchAllHumans:moc_ error:&error];
if (error) {
#if TARGET_OS_IPHONE
NSLog(@"error: %@", error);
#else
[NSApp presentError:error];
#endif
}
return result;
}
+ (NSArray*)fetchAllHumans:(NSManagedObjectContext*)moc_ error:(NSError**)error_ {
NSParameterAssert(moc_);
NSError *error = nil;
NSManagedObjectModel *model = [[moc_ persistentStoreCoordinator] managedObjectModel];
NSDictionary *substitutionVariables = [NSDictionary dictionary];
NSFetchRequest *fetchRequest = [model fetchRequestFromTemplateWithName:@"allHumans"
substitutionVariables:substitutionVariables];
NSAssert(fetchRequest, @"Can't find fetch request named \"allHumans\".");
NSArray *result = [moc_ executeFetchRequest:fetchRequest error:&error];
if (error_) *error_ = error;
return result;
}
@end