• 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: Synthesised properties and additional actions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Synthesised properties and additional actions


  • Subject: Re: Synthesised properties and additional actions
  • From: Matt Neuburg <email@hidden>
  • Date: Sun, 19 Jun 2011 11:01:09 -0700

On Sun, 19 Jun 2011 15:12:31 +1000, Graham Cox <email@hidden> said:
>If I synthesize a property, is it possible to also directly invoke some other code when that property is set (other than the usual KVO)? That is, I need to do something like:
>
>
>@synthesize foo;
>
>
>- (void)		setFoo:(id) newFoo
>{
>      self.foo = newFoo;
>
>     [self doSomethingElseAsWell];
>}
>
>
>Is this kind of thing possible? It looks to me as if the self.foo = line will incur an infinite loop. But if the property is synthesized, to what would I assign the new value?

I provide a good (I think) technique for doing this in my book (p. 275, example 12-5 "Overriding synthesized accessors"). You can also download sample code here:

https://github.com/mattneub/Programming-iOS-4-Book-Examples/tree/master/p275b_overrideSynthesizedAccessors

m.

--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook_______________________________________________

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: Synthesised properties and additional actions
      • From: Dave DeLong <email@hidden>
  • Prev by Date: Re: audiounit instrument with cocoa view
  • Next by Date: Re: CATransactions having no effect in CALayer draw delegate
  • Previous by thread: Re: Synthesised properties and additional actions
  • Next by thread: Re: Synthesised properties and additional actions
  • Index(es):
    • Date
    • Thread