Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C implicit conversion of obj-c pointer to autoreleasing id<protocol> error

I'm having a very specific problem, I'm working with a DAO (data access object) that takes varius states, these states are passed into an init method and are then used.

Now the problem that I'm having is that I can't seem to pass a concrete state into the init method, I always get an

implicit conversion of an objective-c pointer to __autoreleasing id is disallowed with ARC

The code:

-(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
like image 872
user2316452 Avatar asked Dec 08 '22 16:12

user2316452


1 Answers

Remove the star * in

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

id is already defined as a pointer to an instance of a class.

like image 88
Martin R Avatar answered Dec 11 '22 11:12

Martin R