• 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: KVO autonotifying complaining about custom setter return value
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVO autonotifying complaining about custom setter return value


  • Subject: Re: KVO autonotifying complaining about custom setter return value
  • From: Chris Suter <email@hidden>
  • Date: Thu, 6 Mar 2008 10:22:07 +1100


On 06/03/2008, at 10:10 AM, Jim Turner wrote:

Ok first, mmalc, thank you for taking the time to point out exactly
what I needed to see to understand where I was going wrong.  My
problem stemmed from the misguided idea that properties were required
for KVC/KVO.  Chris' comment about "using non-default names" makes
much more sense now.

Second, for my situation, I ended up with an interface that looks like this:

@property (getter=getValueForBindings, setter=setValueForBindings:,
assign, nonatomic) id value;

And an implementation:

-(void) setValueForBindings:(id)_value
{
	[self willChangeValueForKey:@"value"];
	{
		 BOOL didSetOK = [self setStringValue:(NSString *)_value];
              // Do something with didSetOK
	}
	[self didChangeValueForKey:@"value"];
}

-(id) getValueForBindings
{
	return( value );
}

Then binding my interface to the key 'valueForBindings'.  Not the
prettiest, but it's required for my situation.

Thanks again to everyone for all the help.

Why have you got calls to -willChangeValueForKey: and - didChangeValueForKey:? It should probably be done wherever value is changed, if it's not automatic. It's also not clear to me why you can't just name the methods setValue and value (and rename your other methods).


On a separate note, I would personally avoid using identifiers beginning with underscores. I'm pretty sure they are reserved but even if they're not, I would avoid it.

Kind regards,

Chris

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >KVO autonotifying complaining about custom setter return value (From: "Jim Turner" <email@hidden>)
 >Re: KVO autonotifying complaining about custom setter return value (From: "Kyle Sluder" <email@hidden>)
 >Re: KVO autonotifying complaining about custom setter return value (From: Chris Suter <email@hidden>)
 >Re: KVO autonotifying complaining about custom setter return value (From: "Jim Turner" <email@hidden>)
 >Re: KVO autonotifying complaining about custom setter return value (From: mmalc crawford <email@hidden>)
 >Re: KVO autonotifying complaining about custom setter return value (From: "Jim Turner" <email@hidden>)
 >Re: KVO autonotifying complaining about custom setter return value (From: Adam P Jenkins <email@hidden>)
 >Re: KVO autonotifying complaining about custom setter return value (From: mmalc crawford <email@hidden>)
 >Re: KVO autonotifying complaining about custom setter return value (From: "Jim Turner" <email@hidden>)

  • Prev by Date: Re: large documents with doc based app
  • Next by Date: Re: large documents with doc based app
  • Previous by thread: Re: KVO autonotifying complaining about custom setter return value
  • Next by thread: Re: Tabless NSTabView IB3 Bug1
  • Index(es):
    • Date
    • Thread