• 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: Wain <email@hidden>
  • Date: Mon, 24 Apr 2006 20:00:54 +0100

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

  • Prev by Date: Re: PDFKit Removes Line Breaks in Annotations
  • Next by Date: [JOB] Cocoa Developer Needed in the Dallas area.
  • Previous by thread: 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