Re: meaning of if (self = [super init])
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.