• 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: meaning of if (self = [super init])
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: meaning of if (self = [super init])


  • Subject: Re: meaning of if (self = [super init])
  • From: Ben Dougall <email@hidden>
  • Date: Wed, 25 Jun 2003 16:23:56 +0100

On Wednesday, June 25, 2003, at 03:10 pm, Cyprien wrote:

What's the meaning of this code line ?

if (self = [super init])

[super init] returns a pointer if successful, or 0 or null if unsuccessful.

it could go like this:

self = [super init]; // puts a pointer in the variable self
if (self) { // checks that self actually has a valid/useful pointer
...

ifs don't just test for 0 or 1. they test 0, for negative, and any value greater than 0 for positive.

putting self = [super init] in the if test is just a shorter, more concise way of doing it. that part gets run before the if test is made.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: meaning of if (self = [super init])
      • From: "Alastair J.Houghton" <email@hidden>
References: 
 >meaning of if (self = [super init]) (From: Cyprien <email@hidden>)

  • Prev by Date: Re: meaning of if (self = [super init])
  • Next by Date: Re: Properly handling mouseEntered: events
  • Previous by thread: Re: meaning of if (self = [super init])
  • Next by thread: Re: meaning of if (self = [super init])
  • Index(es):
    • Date
    • Thread