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