• 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
Releasing properties?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Releasing properties?
      • From: Keary Suska <email@hidden>
  • Prev by Date: [SOLVED] Re: length of file from NSFileHandle?
  • Next by Date: Re: Releasing properties?
  • Previous by thread: Re: length of file from NSFileHandle?
  • Next by thread: Re: Releasing properties?
  • Index(es):
    • Date
    • Thread