此代码在Xcode 6.2和6.3之间没有变化,但[self alloc]现在包含的行会导致错误:
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
}
//...
Run Code Online (Sandbox Code Playgroud)
如果我Cmd +点击了这个initWithType:电话,我会看到冲突CAEmitterBehavior,我们项目中没有引用的对象,但我猜测必须是iOS 8.3中的新功能.
如果我更改了[self alloc]to [AGNetworkRequest alloc],继承此方法的子类将只返回父对象,这与我们设计此类的方式相反.
如何在不更改方法名称的情况下消除冲突(这需要更改整个应用程序中的所有方法调用)?