> On May 10, 2016, at 10:26 AM, Jonathan Taylor <jonathan.tay...@glasgow.ac.uk> > wrote: > > However, I was a bit surprised to find that I seem to need to explicitly > retain the object I get back [this is non-ARC code…] if I want my request to > remain in effect or even for the object to remain allocated to allow me to > call endActivity at a later point.
It’s standard Cocoa memory management: when an object is returned to you from a method, you don’t own a reference to it, so it’s not guaranteed to remain valid. Since you’re holding onto the object, in order to call -endActivity later, you must be storing it in a non-local variable, so you need to retain it. > My question here is what is the most appropriate way of identifying in code > whether this feature is available, to ensure I only set it when it will be > accepted. Hm, it’s hard to say, because the declaration of DISPATCH_TIMER_STRICT doesn’t specify what OS versions it’s usable with (via __OSX_AVAILABLE_STARTING or something similar.) You may have to do some research to narrow down when it was added. —Jens _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com