0

I am having a problem with a Core Data model in Cocoa. It's probably a fairly basic problem. A section of my Core Data model is shown below. Given the value of a cell property in the OutputCell entity, I want to return the relevant HistogramBar.

Share photos on twitter with Twitpic

I'm using the following Predicate but it just returns an empty array. I've managed to get it working using the Histogram entity but I don't seem to be able to traverse from HistogramBar through Histogram and on to OuputCell. The predicate I'm using is:

NSEntityDescription *histogramBarEntityDescription = [NSEntityDescription entityForName:@"HistogramBar" 
                                                                inManagedObjectContext:[theDocument managedObjectContext]];
NSFetchRequest *histogramBarRequest = [[[NSFetchRequest alloc] init] autorelease];
[histogramBarRequest setEntity:histogramBarEntityDescription];
NSPredicate *histogramBarPredicate = [NSPredicate predicateWithFormat:@"(histogram.outputCell.cell = %@)", theOutputCell];
[histogramBarRequest setPredicate:histogramBarPredicate];
NSError *histogramBarError = nil;
NSArray *histogramsArray = [[theDocument managedObjectContext] executeFetchRequest:histogramBarRequest 
     error:&histogramBarError];

Thankyou for the help.

2
  • Can you post a little more code? I'd like to see the entire fetch request. Commented Mar 2, 2009 at 15:54
  • I've just added the extra code. Commented Mar 2, 2009 at 22:20

1 Answer 1

2

My problem is solved, a rogue comment in the code prevented the HistogramBar entities being created. In this instance detailed checking of some NSLog's helped spot the problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.