Releasing properties?
Releasing properties?
- Subject: Releasing properties?
- From: Andreas Falkenhahn <email@hidden>
- Date: Sat, 27 Aug 2016 13:22:04 +0200
Consider the following example properties:
NSApplication: @property(strong) NSMenu *mainMenu
NSFont: @property(readonly, copy) NSString *familyName
NSColorPanel: @property(copy) NSColor *color
AFAIU I must not release the NSMenu/NSString/NSColor obtained from these
properties because I don't own the objects returned by those properties and
Apple's memory management policy docs clearly say:
"You must not relinquish ownership of an object you do not own"
So I think I've got that right but I'd be glad if somebody could just
confirm that I got it right ;)
I'm just a little confused because of the keywords "strong" and "copy" in
the @property declarations but AFAIU these only refer to setting those
properties, not getting those properties, i.e. the object is copied when
*setting* the property, not when *getting* it. Right?
And another question: Can it also happen that a class has a property
which returns an object which I *must* release or is it a general rule
that getting a @property always returns objects which I do not own
and hence mustn't released?
Thanks!
--
Best regards,
Andreas Falkenhahn mailto:email@hidden
_______________________________________________
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