• 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, can you issue an NSrequest from awakefrominsert
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core-Data, can you issue an NSrequest from awakefrominsert


  • Subject: Re: Core-Data, can you issue an NSrequest from awakefrominsert
  • From: R Dearlove <email@hidden>
  • Date: Mon, 24 Apr 2006 21:08:06 +0100


Thanks for that. It seems I will have to subclass the array controller and put some code in there. I tried the delayed selector calling method shown on the page, but that crashes my app.
It's a shame that there isn't an auto-inc field type in coredata.


thanks again
R Dearlove

On 24 Apr 2006, at 20:00, Wain wrote:

Hi,

Browse through http://www.cocoabuilder.com/archive/message/cocoa/ 2005/9/5/145761 for an explanation and solution.

Wain

On 24 Apr 2006, at 18:43, Richard Dearlove wrote:

In a test app, I incremented a textfield by looking up a value from an entity which stored in the key form "name" & "value", which i then incremented

I just moved to my proper app, and tried to add the code into the awakeFromInsert method for the ManagedObject,

The problem is that calling the executeFetchRequest method causes my bound NSTableView to show 2 new records for every 1 inserted.
What am I doing wrong. ??


I saw someone else doing something similar on Cocoadev but thought i'd avoided the same problem

regards
R Dearlove


@implementation receipt
- (void)awakeFromInsert
{
[super awakeFromInsert]; // Call superclass first



// Ask the managed object context what the value should be - look it up the entity for the Values:receipt_#:
NSManagedObjectContext *moc = [self managedObjectContext];

id request = [[[NSFetchRequest alloc] init] autorelease];


NSEntityDescription *counter = [NSEntityDescription entityForName: @"values" inManagedObjectContext: moc];
NSPredicate *searchPredicate = [ NSPredicate predicateWithFormat:@"name=%@",@"ID" ];
NSSortDescriptor *sortDesc = [[ NSSortDescriptor alloc ] initWithKey:@"name" ascending:YES ];// autorelease ];

[ request setEntity:counter]; // Set Request using counters
[ request setPredicate:searchPredicate]; // Set Predicate for search
[ request setSortDescriptors:[NSArray arrayWithObject:sortDesc ] ]; // Set Sort Order for searc

id error = nil;

NSArray *arrayResults = [ moc executeFetchRequest:request error: &error]; // <-------- THIS LINE, CAUSES DUPLICATES TO APPEAR


// more code...........

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40tekuris.com


This email sent to email@hidden

_______________________________________________ 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

_______________________________________________ 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
  • Follow-Ups:
    • Re: Core-Data, can you issue an NSrequest from awakefrominsert
      • From: Chris Hanson <email@hidden>
References: 
 >Core-Data, can you issue an NSrequest from awakefrominsert (From: Richard Dearlove <email@hidden>)
 >Re: Core-Data, can you issue an NSrequest from awakefrominsert (From: Wain <email@hidden>)

  • Prev by Date: Re: Which exception handling system should I use?
  • Next by Date: Re: Getting a machine's MAC address
  • Previous by thread: Re: Core-Data, can you issue an NSrequest from awakefrominsert
  • Next by thread: Re: Core-Data, can you issue an NSrequest from awakefrominsert
  • Index(es):
    • Date
    • Thread