• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core Data compare NSNumber question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >Core Data compare NSNumber question (From: Ryan Moniz <email@hidden>)

  • Prev by Date: Core Data compare NSNumber question
  • Next by Date: Re: Crash in objc_msgSend_rtp when calling add action of NSArrayController
  • Previous by thread: Core Data compare NSNumber question
  • Next by thread: RE: Core Data: Master-Detail question <-- 'contextSet' binding doesn't appear to work.
  • Index(es):
    • Date
    • Thread