• 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: Listening for changes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Listening for changes


  • Subject: Re: Listening for changes
  • From: Keary Suska <email@hidden>
  • Date: Fri, 19 Dec 2008 11:51:44 -0700


On Dec 19, 2008, at 11:36 AM, Andre Masse wrote:

Hmm.. Thought this would be easy but I'm stuck...

Here's what I've done:

- added the fake property BOOL needSaving
  @property(assign, nonatomic) BOOL needSaving;
 @synthesize needSaving;

- implemented keyPathsForValuesAffecting (I'm on Leopard)

+ (NSSet*)keyPathsForValuesAffectingValueForKey:(NSString*)key
{
	NSSet* set = [super keyPathsForValuesAffectingValueForKey:key];

	if ([key isEqualToString:@"needSaving"]) {
		set = [set setByAddingObjectsFromSet:[NSSet setWithObjects:
									@"lastName",
									@"firstName",
									  ...
									 nil]];
	}

	return set;
}

Now, I just can't figure out how I should implement - (BOOL) needSaving! Setting it to NO in -init and implementing it like this obviously doesn't work:

- (BOOL) needSaving
{
	return YES;
}


As I understand this approach, it doesn't matter. All you should need to do is observe the "fake" property, and in the observeValueForKeyPath call do whatever you need to do. The + keyPathsForValuesAffectingValueForKey: call just (eventually) causes a KVO notice to be sent for the dependent property. So in this approach, you are coalescing all of the individual calls into one call.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: Listening for changes
      • From: Andre Masse <email@hidden>
References: 
 >Listening for changes (From: Andre Masse <email@hidden>)
 >Re: Listening for changes (From: Ken Thomases <email@hidden>)
 >Re: Listening for changes (From: Andre Masse <email@hidden>)

  • Prev by Date: Re: NSData downloaded over socket is bigger than it should be...
  • Next by Date: Re: Listening for changes
  • Previous by thread: Re: Listening for changes
  • Next by thread: Re: Listening for changes
  • Index(es):
    • Date
    • Thread