• 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
Fetch request problem with core data relationship and NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fetch request problem with core data relationship and NSTableView


  • Subject: Fetch request problem with core data relationship and NSTableView
  • From: "Danny Callanan" <email@hidden>
  • Date: Fri, 15 Jun 2007 11:55:34 +0100
  • Organization: Oracle

I've encountered a strange problem when using a fetch request to default a value into a new NSManagedObject relationship.

I'm using core data and have two entities, 'Charge' and 'Currency', with a many:1 relationship between them called 'toCurrency'. I've depicted the 'Charge' entity in the UI within an NSTableView.

So far so good. I want the system to default in a value for currency when the user creates a 'Charge' object. To do this, I've specified the following fetch request and added it to the awakeFromInsert method within a 'Charge' class (subbed from NSManagedObject):

NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"Currency" inManagedObjectContext:moc];
[request setEntity:entity];
NSError *error = nil;
NSArray *tempArray = [moc executeFetchRequest:request error:&error];
[self setToCurrency:[self [tempArray lastObject]]];

This is very crudely bringing back the last Currency object (I'll want to refine this).

All appears to work except that the UI shows two new rows rather than one when the user adds a Charge object. This appears to be a problem with UI only however since if I quit the application and re-open it only a single row appears.

My head is feeling sore with all the scratching! I'd really appreciate any help.

Many thanks
Danny
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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

  • Follow-Ups:
    • Re: Fetch request problem with core data relationship and NSTableView
      • From: "I. Savant" <email@hidden>
  • Prev by Date: Re: RS: Debugging question
  • Next by Date: Re: Fetch request problem with core data relationship and NSTableView
  • Previous by thread: Re: RS: Debugging question
  • Next by thread: Re: Fetch request problem with core data relationship and NSTableView
  • Index(es):
    • Date
    • Thread