Objective-C将obj-c指针隐式转换为autoreleasing id <protocol>错误

use*_*452 3 compiler-errors objective-c implicit-conversion automatic-ref-counting

我有一个非常具体的问题,我正在使用一个采用varius状态的DAO(数据访问对象),这些状态被传递到init方法然后被使用.

现在我遇到的问题是我似乎无法将具体状态传递给init方法,我总是得到一个

使用ARC不允许将Objective-c指针隐式转换为__autoreleasing id

代码:

-(DAOObject *)makeSpecificDataAccessObject{
    SQLiteState* localstate = [[SQLiteState alloc] initWithTableName:@"TableName"];
    DAOObject* specificDAO = [[DAOObject alloc] initWithLocalState:localstate]; //where error happens
    return specificDAO;
}

@interface DAOObject : NSObject <SettingsListenerProtocol>
    -(id)initWithLocalState:(id<StateProtocol> *)LocalState;
@end

@interface SQLiteState : NSObject <StateProtocol>
-(id)initWithTableName:(NSString *)tableName;

@end
Run Code Online (Sandbox Code Playgroud)

Mar*_*n R 13

卸下明星*

-(id)initWithLocalState:(id<StateProtocol> *)LocalState;
Run Code Online (Sandbox Code Playgroud)

id已经被定义为指向类实例的指针.