• 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 - awakeFromInsert
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data - awakeFromInsert


  • Subject: Re: Core Data - awakeFromInsert
  • From: Jim Murry <email@hidden>
  • Date: Wed, 5 Oct 2005 11:54:54 -0700


This was just a simple version to describe the problem I was having

On Oct 4, 2005, at 6:04 PM, mmalcolm crawford wrote:


On Oct 4, 2005, at 4:43 PM, Jim Murry wrote:


I am trying to implement defaults by creating a core data object to hold these defaults.


It's not clear why you're trying to do this (in this way)...

I was just trying to take a value from an entity "Defaults" as masterRecord.recordID then and set the recordID in a newly created entity "Customer". Maybe "Defaults" was not the best choice for the entity name in the example. I am just trying to use value from a fetched record to set value in a new record sometimes in the same entity.


When I perform a fetch within awakeFromInsert I get two entries showing up in the array.


This way they do not reset to zero when the program is run from a different user or a different machine as long as they have access to the same core data file.


... you can establish "factory settings" (NSRegistrationDomain) for user defaults much more easily (see <http://developer.apple.com/ documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/ NSUserDefaults.html#//apple_ref/doc/uid/20000318-CIHDDCDB>).



What are you actually trying to achieve?



[masterRecord willChangeValueForKey: @"recordID"];
[masterRecord setPrimitiveValue:[NSNumber numberWithLongLong: (value + 1)] forKey:@"recordID"];
[masterRecord didChangeValueForKey: @"recordID"];
[self setPrimitiveValue:[NSNumber numberWithLongLong:(value)] forKey:@"recordID"];



Don't do this!
Either use the standard KVO-compliant accessors or use the primitive accessors. It's not clear what you're trying to achieve doing this, or why.

[masterRecord willChangeValueForKey: @"recordID"]; // I did this so the next line would persist


[masterRecord setPrimitiveValue:[NSNumber numberWithLongLong: (value + 1)] forKey:@"recordID"]; // is this wrong? This is a fetched record and it
// would not persist without the other lines.
[masterRecord didChangeValueForKey: @"recordID"]; // I did this so previous line would persist


[self setPrimitiveValue:[NSNumber numberWithLongLong:(value)] forKey:@"recordID"]; // This is where I was setting recordID in the
// newly created record for the value fetched
// from a different record, is this line wrong as
// well?


Jim

_______________________________________________
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


References: 
 >Core Data - awakeFromInsert (From: Jim Murry <email@hidden>)
 >Re: Core Data - awakeFromInsert (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Convert Windows file path to Mac File path
  • Next by Date: CoreData: Avoiding unresolved key path exception with SQLite store?
  • Previous by thread: Re: Core Data - awakeFromInsert
  • Next by thread: QTMovieView and HTTP Redirects
  • Index(es):
    • Date
    • Thread