user2316452
user2316452

Reputation: 63

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

Upvotes: 6

Views: 5643

Answers (1)

Martin R
Martin R

Reputation: 539805

Remove the star * in

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

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

Upvotes: 17

Related Questions