Changeset 324
- Timestamp:
- 08/27/08 15:19:20 (3 months ago)
- Files:
-
- trunk/cocoa/mogenerator/mogeneratorTestMule/MOs/_HumanMO.h (modified) (1 diff)
- trunk/cocoa/mogenerator/mogeneratorTestMule/MOs/_HumanMO.m (modified) (5 diffs)
- trunk/cocoa/mogenerator/templates/machine.h.motemplate (modified) (1 diff)
- trunk/cocoa/mogenerator/templates/machine.m.motemplate (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cocoa/mogenerator/mogeneratorTestMule/MOs/_HumanMO.h
r319 r324 49 49 50 50 51 + ( id)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_;52 + ( id)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ error:(NSError**)error_;51 + (NSArray*)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_; 52 + (NSArray*)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ error:(NSError**)error_; 53 53 54 54 trunk/cocoa/mogenerator/mogeneratorTestMule/MOs/_HumanMO.m
r319 r324 78 78 79 79 80 + ( id)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ {80 + (NSArray*)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ { 81 81 NSError *error = nil; 82 idresult = [self fetchByHumanName:moc_ humanName:humanName_ error:&error];82 NSArray *result = [self fetchByHumanName:moc_ humanName:humanName_ error:&error]; 83 83 if (error) { 84 84 [NSApp presentError:error]; … … 86 86 return result; 87 87 } 88 + ( id)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ error:(NSError**)error_ {88 + (NSArray*)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ error:(NSError**)error_ { 89 89 NSError *error = nil; 90 90 … … 99 99 NSAssert(fetchRequest, @"Can't find fetch request named \"byHumanName\"."); 100 100 101 id result = nil; 102 NSArray *results = [moc_ executeFetchRequest:fetchRequest error:&error]; 103 104 if (!error) { 105 switch ([results count]) { 106 case 0: 107 // Nothing found matching the fetch request. That's cool, though: we'll just return nil. 108 break; 109 case 1: 110 result = [results objectAtIndex:0]; 111 break; 112 default: 113 NSAssert1(NO, @"byHumanName: 0 or 1 objects expected, %u found", [results count]); 114 } 115 } 116 101 NSArray *result = [moc_ executeFetchRequest:fetchRequest error:&error]; 117 102 if (error_) *error_ = error; 118 103 return result; … … 133 118 134 119 NSManagedObjectModel *model = [[moc_ persistentStoreCoordinator] managedObjectModel]; 135 NSFetchRequest *fetchRequest = [model fetchRequestFromTemplateWithName:@"oneByHumanName" 136 substitutionVariables:[NSDictionary dictionaryWithObjectsAndKeys: 120 NSDictionary *substitutionVariables = [NSDictionary dictionaryWithObjectsAndKeys: 137 121 138 122 humanName_, @"humanName", 139 123 140 nil] 141 ]; 124 nil]; 125 NSFetchRequest *fetchRequest = [model fetchRequestFromTemplateWithName:@"oneByHumanName" 126 substitutionVariables:substitutionVariables]; 142 127 NSAssert(fetchRequest, @"Can't find fetch request named \"oneByHumanName\"."); 143 128 … … 154 139 break; 155 140 default: 156 NSAssert1(NO, @"oneByHumanName: 0 or 1 objects expected, %u found", [results count]); 141 NSLog(@"WARN fetch request oneByHumanName: 0 or 1 objects expected, %u found (substitutionVariables:%@, results:%@)", 142 [results count], 143 substitutionVariables, 144 results); 157 145 } 158 146 } trunk/cocoa/mogenerator/templates/machine.h.motemplate
r319 r324 49 49 <$endforeach do$> 50 50 <$foreach FetchRequest prettyFetchRequests do$> 51 <$if Relationship.singleResult$>51 <$if FetchRequest.singleResult$> 52 52 + (id)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_<$endforeach do2$>; 53 53 + (id)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_<$endforeach do2$> error:(NSError**)error_; trunk/cocoa/mogenerator/templates/machine.m.motemplate
r319 r324 117 117 118 118 <$foreach FetchRequest prettyFetchRequests do$> 119 <$if Relationship.singleResult$>119 <$if FetchRequest.singleResult$> 120 120 + (id)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_<$endforeach do2$> { 121 121 NSError *error = nil;
