• 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: do you init your instance variables in init method or outside the class?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: do you init your instance variables in init method or outside the class?


  • Subject: Re: do you init your instance variables in init method or outside the class?
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Wed, 18 Jul 2012 15:12:59 +0200

Le 18 juil. 2012 à 15:03, Chris Ridd <email@hidden> a écrit :

>
> On 18 Jul 2012, at 08:09, Lee Ann Rucker wrote:
>
>> In init, and only when they need it. They're all initialized to nil, which is a perfectly reasonable value for an instvar to have; there's very rarely a reason to do anything like
>>
>>>   name = [NSString string];
>>
>> because sending a method to nil is perfectly safe, unlike C++.
>>
>>>   foodLists = [NSMutableArray array];
>>
>> is necessary, as you've seen, but not for the reasons you think.
>
> Both of those lines are going to cause random crashes later on because they're non-retained objects.
>

They are perfectly valid lines in the new ARC world.

-- Jean-Daniel





_______________________________________________

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: 
 >Re: do you init your instance variables in init method or outside the class? (From: Lee Ann Rucker <email@hidden>)
 >Re: do you init your instance variables in init method or outside the class? (From: Chris Ridd <email@hidden>)

  • Prev by Date: Re: KVG generic enough?
  • Next by Date: Re: KVG generic enough?
  • Previous by thread: Re: do you init your instance variables in init method or outside the class?
  • Next by thread: Re: Trap mouse and keyboard events
  • Index(es):
    • Date
    • Thread