• 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: Why would a defined selector not be found at runtime?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why would a defined selector not be found at runtime?


  • Subject: Re: Why would a defined selector not be found at runtime?
  • From: Sherm Pendley <email@hidden>
  • Date: Thu, 12 May 2005 14:12:07 -0400

On May 12, 2005, at 11:37 AM, Ricky Sharp wrote:

On May 12, 2005, at 4:46 AM, Ken Tozier wrote:

     NSDisclosureButtonCell    *result        =
[NSDisclosureButtonCell alloc];

     // always chokes on the next line at runtime
     [result  initWithControlSize: inControlSize];

Hmm, I think this has something to do with splitting up the alloc and init calls.

The problem with splitting those up is that -init* is not required to return the object that received it. It might return nil, or even another object.


So, in the above, result would be fine after the call to +alloc, but if -init* returned nil or a different object, result would be a wayward pointer.

Incidentally, if you *really* want to split up the +alloc and -init* calls, you can, but you have to remember to re-assign the variable with the return value from -init*:

NSFoo *anObject = [NSFoo alloc];
anObject = [anObject init];

This is a safe way to split them, but it's awkward and error-prone, so hardly anyone ever uses it.

sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

_______________________________________________
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: Why would a defined selector not be found at runtime?
      • From: Ken Tozier <email@hidden>
References: 
 >Why would a defined selector not be found at runtime? (From: Ken Tozier <email@hidden>)
 >Re: Why would a defined selector not be found at runtime? (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Re: Why would a defined selector not be found at runtime?
  • Next by Date: Re: Why would a defined selector not be found at runtime?
  • Previous by thread: Re: Why would a defined selector not be found at runtime?
  • Next by thread: Re: Why would a defined selector not be found at runtime?
  • Index(es):
    • Date
    • Thread