4

我遇到了一个非常具体的问题,我正在使用具有各种状态的 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
4

1 回答 1

14

*去掉里面的星星

-(id)initWithLocalState:(id<StateProtocol> *)LocalState;

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

于 2013-04-24T16:21:05.187 回答