• 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
Custom setter for atomic property
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Custom setter for atomic property


  • Subject: Custom setter for atomic property
  • From: Jonny Taylor <email@hidden>
  • Date: Thu, 28 Oct 2010 15:01:44 +0100

I currently have a property declared as follows:
@property(atomic, readwrite, retain) MyFrame* latestFrame;

When the value is set, I would like to broadcast a notification on the main thread, and one way of doing that would be to write my own custom setter that sets the value and then broadcasts the notification. What I am not sure about is how much I need to do to ensure this is threadsafe. I have only been able to find limited, rather contradictory information on this.

When I write my own setter function, does the "atomic" qualifier have any meaning? What I am trying to work out is whether the runtime will bracket my function with appropriate locking code, or whether I need to do that myself - and so crucially, do I ALSO need to write a custom getter function that is subject to the same manual locking?

[I have since wondered whether actually the "right" way of achieving what I want is to implement a didChangeValueForKey method from which I do the broadcasting. Any comments on that approach would also be welcome!]

Thanks in advance
Jonny_______________________________________________

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: Custom setter for atomic property
      • From: Bill Bumgarner <email@hidden>
  • Prev by Date: Re: NSMomentaryLightButton vs. NSMomentaryPushInButton and NSPushOnPushOffButton vs. NSOnOffButton
  • Next by Date: Re: Custom setter for atomic property
  • Previous by thread: Re: Adding and removing menu items causes memory usage to grow
  • Next by thread: Re: Custom setter for atomic property
  • Index(es):
    • Date
    • Thread