[MacRuby-devel] super method

Thibault Martin-Lagardette thibault.ml at gmail.com
Wed Sep 8 20:18:52 PDT 2010


Yes, I am very, very sorry I forgot the completely necessary `if (self = [super init])`. It's been a while since I last wrote actual Obj-C code haha.
Thank you for correcting me!

-- 
Thibault Martin-Lagardette



On Sep 8, 2010, at 16:27, russell muetzelfeldt wrote:

> On 09/09/2010, at 4:22 AM, macruby-devel-request at lists.macosforge.org wrote:
> 
>> Date: Wed, 8 Sep 2010 11:22:37 -0700
>> From: Thibault Martin-Lagardette <thibault.ml at gmail.com>
>> 
>>> I don't think I've seen any examples using the initWith method. Is that method called after init?
>> 
>> Simply something of the like:
>> 
>> - (id)initWithDelegate:(id)someDelegate
>> {
>>   [self setDelegate:someDelegate];
>> }
>> 
>> or
>> 
>> - (id)initWithColor:(MRColor)color andBorderSize:(int)borderSize
>> {
>>   [self setCubeColor:color];
>>   [self setBorderSize:borderSize];
>> }
> 
> Those are never actually initialising the object - do you mean something like this? (assuming the class in question doesn't inherit from something with a different designated initialiser)
> 
> 
> - (id)initWithDelegate:(id)someDelegate
> {
>  if (self = [super init])
>  {
>    [self setDelegate:someDelegate];
>  }
>  return self
> }
> 
> or
> 
> - (id)initWithColor:(MRColor)color andBorderSize:(int)borderSize
> {
>  if (self = [super init])
>  {
>    [self setCubeColor:color];
>    [self setBorderSize:borderSize];
>  }
>  return self;
> }
> 
> 
> cheers
> 
> Russell
> 
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel



More information about the MacRuby-devel mailing list