This code did not change between Xcode 6.2 and 6.3, but the line containing [self alloc]
now causes the error:
Multiple methods named 'initWithType:' found with mismatched result, parameter type or attributes
@implementation AGNetworkDataRequest
+ (instancetype)networkDataRequestWithType:(AGNetworkDataRequestType)type
{
AGNetworkDataRequest *r = [[self alloc] initWithType:type];//error here
return r;
}
- (id)initWithType:(AGNetworkDataRequestType)type
{
//typical init code
}
//...
If I Cmd+click on the initWithType:
call, I am shown the conflict in CAEmitterBehavior
, an object not referenced in our project at all, but I'm guessing must be new in iOS 8.3.
If I change the [self alloc]
to [AGNetworkRequest alloc]
, the subclasses inheriting this method will just return the parent object, which acts in opposition to how we designed this class.
Any way to eliminate the conflict without changing the method name (which requires changing all method calls throughout the app)?
initWithType:
method should returninstancetype
, notid
. Make sure all of yourinit...
methods are declared withinstancetype
. – Toxinantitoxinid
forinit
andinstancetype
for convenience constructors. Do you have a link to Apple docs stating allinit
s should beinstancetype
? – Headboardinit...
method and see that it returnsinstancetype
. For example:UITableView initWithFrame:style:
orNSArray init
. All of theid
return types forinit...
methods was changed toinstancetype
by Apple in some recent iOS update (I forget which one). – Toxinantitoxininit
return type toinstancetype
does not fix the issue. – Headboard