• 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
KVO and Coredata/Undo Clarification
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

KVO and Coredata/Undo Clarification


  • Subject: KVO and Coredata/Undo Clarification
  • From: email@hidden
  • Date: Wed, 15 Mar 2006 18:27:05 -0800

Hi List.

If I have an attribute called "foobared" thats just a bool, and is transient, if I called [self willChangeValueForKey:@"foobared"] [self didChangeValueForKey:@"foobared"] 5 times, with that result in 5 undo's in the stack even if there was no change, or does NSPersistenDocument know to record changes only to a variable if its core data (not a custom ivar) value changed?

As a real example, I have an object where its binary data is kept in a child object.
So I have two objects: Binary and Data, Data actually holds the binary info, and Binary holds other information, such as its name, data type etc.


Binary <---> Data

Here is how I set the value from Binary to Data:

- (void)setValue:(NSData *)value
{
    [self willChangeValueForKey: @"value"];
    [[self valueForKey:@"data"] setValue: value forKey: @"value"];
    [self didChangeValueForKey: @"value"];
}

And retrieve it:

- (NSData *)value
{
    NSData * tmpValue;

    [self willAccessValueForKey: @"value"];
    tmpValue = [[self valueForKey:@"data"] valueForKey: @"value"];
    [self didAccessValueForKey: @"value"];

    return tmpValue;
}

Is this the right way, I'm especially worried about the setValue method because it creates two change notifications..... because Binary basically "hides" the Data object.
Is this something to be worried about? Should I be using primitiveValueForKey??


Any help is of course appreciated.

Andre
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: KVO and Coredata/Undo Clarification
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: Re: Maximum simultaneous NSURLConnections?
  • Next by Date: Re: KVO and Coredata/Undo Clarification
  • Previous by thread: Re: Changing NSTableView DataSource without glitching
  • Next by thread: Re: KVO and Coredata/Undo Clarification
  • Index(es):
    • Date
    • Thread