Re: Core Data compare NSNumber question
Re: Core Data compare NSNumber question
- Subject: Re: Core Data compare NSNumber question
- From: mmalcolm crawford <email@hidden>
- Date: Fri, 23 Dec 2005 19:40:29 -0800
On Dec 23, 2005, at 7:02 PM, Ryan Moniz wrote:
I want to get an array with objects at a specified time.
- (NSArray *)getObjectsForTime:(NSNumber *)aTime {
NSDictionary *entityDict = [managedObjectModel
entitiesByName];
NSEntityDescription *entityDescription = [entityDict
valueForKey:@"Time"];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:entityDescription];
NSPredicate *predicate = [NSPredicate
predicateWithFormat:@"time = %@", aTime ];
[fetchRequest setPredicate:predicate];
NSArray *array = [[managedObjectContext
executeFetchRequest:fetchRequest error:nil] retain];
[fetchRequest release];
return [array autorelease];
}
after the data is loaded, and this method is called I get:
array = (null)
First, it's not clear why you're retaining the returned array only to
autorelease it later?
Second, per the documentation (<
http://developer.apple.com/
documentation/Cocoa/Reference/CoreData_ObjC/Classes/
NSManagedObjectContext.html#//apple_ref/occ/instm/
NSManagedObjectContext/executeFetchRequest:error:>),
executeFetchRequest:error: returns nil of an error occurs. You
should typically pass a pointer to an NSError object as the error
argument, then if an error occurs you can find out what went wrong...
Finally, is it possible that it's not the case that an error is
occurring, but that managedObjectContext is nil?
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden