• 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: self = [super init], nil?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: self = [super init], nil?


  • Subject: Re: self = [super init], nil?
  • From: Kyle Sluder <email@hidden>
  • Date: Sat, 8 May 2010 08:12:46 -0700

On May 8, 2010, at 7:12 AM, gandreas <email@hidden> wrote:

A subtle but important point is that after init's self=[super init] is the only time you normally could have self being NULL (the only other time I can think of is when you do some form of IMP caching and explicitly call the method with nil as the first parameter, but this is pretty rare). So this means it is the only place where accessing an ivar directly can cause a null dereference (unlike C++ where this can be null in any case where static typing allows bypassing vtable dispatching, requiring extra care and paranoia).

For speed or correctness, we do TONS of pointer-identity dictionary or other data structure stuff. Not much IMP caching, but often methods will call C functions that take a "self" argument (so that they can call themselves recursively without going through method dispatch each time).


Now that we have blocks, I expect we'll be using a lot less of this, but with our current codebase it pays to be safe.

--Kyle Sluder

_______________________________________________

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: self = [super init], nil?
      • From: Kyle Sluder <email@hidden>
References: 
 >self = [super init], nil? (From: "Patrick M. Rutkowski" <email@hidden>)
 >Re: self = [super init], nil? (From: Kyle Sluder <email@hidden>)
 >Re: self = [super init], nil? (From: Roland King <email@hidden>)
 >Re: self = [super init], nil? (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: self = [super init], nil?
  • Next by Date: Re: self = [super init], nil?
  • Previous by thread: Re: self = [super init], nil?
  • Next by thread: Re: self = [super init], nil?
  • Index(es):
    • Date
    • Thread