Re: Having problem with fetch request in NSDocument based application
Re: Having problem with fetch request in NSDocument based application
- Subject: Re: Having problem with fetch request in NSDocument based application
- From: Brent Gulanowski <email@hidden>
- Date: Sat, 5 Sep 2009 09:55:12 -0400
Perhaps you would like to compare your code to some open source code
that's out there. I've got a persistent document-based app available
here:
http://bitbucket.org/bgulanowski/branchline/
The app is alpha and moribund, but the Core Data part works fine. It
uses SQLite, not XML, but you could change that yourself.
It's a point of comparison, at least.
Cheers,
-b-
On Fri, Sep 4, 2009 at 7:32 PM, Clayton Leitch<email@hidden> wrote:
> URL is correct and entity is not nil.
> On Sep 4, 2009, at 12:55 PM, Brent Gulanowski wrote:
>
>> So, all the other objects leading to the fetch execute look OK? Your
>> context isn't nil? Does your context actually have the right store
>> coordinator with the right store URL? Does NSEntityDescription return
>> an entity, and not nil? Does your context have a managed object model?
>>
>>
>> On Fri, Sep 4, 2009 at 9:47 AM, Clayton Leitch<email@hidden> wrote:
>>>
>>> Here is the code in MyDocument:
>>> -(IBAction)calculateStat:(id)sender{
>>> fetchedObjects = nil;
>>> context = [self managedObjectContext];
>>> fetchRequest = [[NSFetchRequest alloc] init];
>>> entity = [NSEntityDescription entityForName:@"Measurement"
>>> inManagedObjectContext:context];
>>> [fetchRequest setEntity:entity];
>>> fetchedObjects = [context executeFetchRequest:fetchRequest
>>> error:&error];
>>> if (fetchedObjects == nil) {
>>> NSLog(@"error");
>>> [errorMessage setStringValue:@"no objects"];
>>> }else {
>>> [errorMessage setIntValue:[fetchedObjects count]];
>>> }
>>>
>>>
>>> [fetchRequest release];
>>> The fetchedObjects count is always 0. Any idea what silly thing I
>>> forgot.
>>>
>>> Thanks
>>
>> --
>> Brent Gulanowski
>
>
--
Brent Gulanowski
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden