[MacRuby-devel] super method
russell muetzelfeldt
russm-macruby-devel at slofith.org
Wed Sep 8 16:27:39 PDT 2010
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
More information about the MacRuby-devel
mailing list