I have a method like this which performs further initializations on other objects with similar init methods.
- (Foo*)initWithInput:(NSMutableString*)i {
bar = [[Bar alloc] initWithInput:input];
return self;
}
This produces a warning "Foo.m:19: warning: incompatible Objective-C types assigning 'struct Foo *', expected 'struct Bar *'"
I am assuming the alloc method is returning an (id) type and then the compiler can't decide which initWithInput: method I want to use on the allocated object. I can of course remove the warning like this but it's not terribly pretty
- (Foo*)initWithInput:(NSMutableString*)i {
bar = [((Bar*)[Bar alloc]) initWithInput:input];
return self;
}
Is there an idiomatic way of handling this?