In Objective C, a custom init method must call the superclass's designated initializer. Consider the following custom init method for a sublcass of NSView:
- (void)initWithFrame:(CGRect)aFrame andName:(NSString *)aName {
if(self = [super initWithFrame:aFrame]){
//set up object
}
}
However, MacRuby only offers the super
keyword, which simply tries calling the same method in the superclass. Since this is a custom initializer, however, the superclass has no such method.
What is the standard way of solving this? I did see this question: MacRuby custom initializers but I can't say I understand the answer very well, nor does it seem to be some broadly accepted solution. Since MacRuby is now a few years older than when that post was written, I'm hoping a clearer, standard solution now exists.