• 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: checking if an object's instance exists.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: checking if an object's instance exists.


  • Subject: Re: checking if an object's instance exists.
  • From: Kevin Ballard <email@hidden>
  • Date: Sat, 5 Feb 2005 15:14:16 -0500

On Feb 5, 2005, at 3:01 PM, daniel wrote:

It took me a while to get comfortable with the "everything is inited to nil, and nil is safe to message" mindset that goes with Cocoa, but it's in there firm now and I don't deny it. I don't manually initialize ivars to nil anymore than I check for nil before messaging an object. Just do it.

Another comparison would be IBOutlet connections. This is something that is done for you contractually by the environment you're working in. It might add clarity to add code to your awakeFromNib method to manually go through and reconnect them all, but it would be a waste of effort.

That's a bad analogy. IBOutlets are set for you in the nib file. It would be like saying archives store all the properties of the archived object, but it would add clarity to re-set those properties after unarchiving, which is just plain wrong. With IBOutlet, you have set everything in the nib file. With ivars, I think it adds clarity to init them to nil or 0 or whatever in the initializer for clarity. That way I can look at the initializer and find what the default value is - whether it's nil/0 or whether it's some other preset value. But I do recognize that this is simply preference, just like whether or not you put the opening brace of a method on the same line as the method name or on the next line.


--
Kevin Ballard
email@hidden
http://www.tildesoft.com
http://kevin.sb.org

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: checking if an object's instance exists.
      • From: daniel <email@hidden>
References: 
 >checking if an object's instance exists. (From: Aaron Boothello <email@hidden>)
 >Re: checking if an object's instance exists. (From: Kevin Ballard <email@hidden>)
 >Re: checking if an object's instance exists. (From: Sherm Pendley <email@hidden>)
 >Re: checking if an object's instance exists. (From: Kevin Ballard <email@hidden>)
 >Re: checking if an object's instance exists. (From: daniel <email@hidden>)

  • Prev by Date: Re: How do you use the space key as a key equivalent
  • Next by Date: Re: How do you use the space key as a key equivalent
  • Previous by thread: Re: checking if an object's instance exists.
  • Next by thread: Re: checking if an object's instance exists.
  • Index(es):
    • Date
    • Thread