• 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: @property and automatic synthesis of getters and setters.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: @property and automatic synthesis of getters and setters.


  • Subject: Re: @property and automatic synthesis of getters and setters.
  • From: Aaron Montgomery <email@hidden>
  • Date: Thu, 12 Sep 2013 15:09:41 -0700

On Sep 12, 2013, at 3:02 PM, Lee Ann Rucker <email@hidden> wrote:

>
> On Sep 12, 2013, at 2:52 PM, Aaron Montgomery wrote:
>>
>> I think it is either
>> _protoCell = [[Cell alloc] init];
>> or
>> self.protoCell = [[Cell alloc] init];
>
> These aren't equivalent unless the @property is assign, which usually is not what you want for object instvars that you intend to own.
>
> @property (readwrite, retain) protoCell;
>
> _protoCell = [[Cell alloc] init];
> self.protoCell = [[[Cell alloc] init] autorelease];
> self.protoCell = [foo somethingThatReturnsAProtoCell]; // since getters generally do not provide a retained object; see earlier discussions today :)
>
> self.protoCell = nil;
> [_protoCell release]; _protoCell = nil;

Right, the original poster will need to decide which one has appropriate semantics for his situation. Just providing him with his two syntactic options. Since he is doing this work in an initializer, I suspect he will want direct ivar access. If he wants to use the property access and isn't using ARC, he will need the autorelease.

Aaron



_______________________________________________

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


References: 
 >@property and automatic synthesis of getters and setters. (From: Peter Teeson <email@hidden>)
 >Re: @property and automatic synthesis of getters and setters. (From: Aaron Montgomery <email@hidden>)
 >Re: @property and automatic synthesis of getters and setters. (From: Lee Ann Rucker <email@hidden>)

  • Prev by Date: Re: @property and automatic synthesis of getters and setters.
  • Next by Date: quitting app running in status bar logs this message about some modal session
  • Previous by thread: Re: @property and automatic synthesis of getters and setters.
  • Next by thread: Re: @property and automatic synthesis of getters and setters.
  • Index(es):
    • Date
    • Thread