我正在 Implicit conversion of an Objective-C pointer to '__autoreleasing id<MY_AccountDAO>' is disallowed with ARC
。
我回顾了这个问题:Passing object pointer as protocol pointer但这是一个不同的问题,我已经在答案中使用了建议的语法。
我收到了错误:
[accountService setAccountDAO:accountDAO];
具体来说,accountDAO
引用下面有一个小的橙色三角形。
@implementation MY_Bootstrapper
#import "MY_Bootstrapper.h"
#import "MY_MainController.h"
#import "MY_ServiceManager.h"
#import "MY_FileSystemAccountDAO.h"
#import "MY_AccountDAO.h"
#import "MY_AccountService.h"
#import "MY_BasicAccountService.h"
@implementation MY_Bootstrapper
-(MY_MainController *)initializeMainController{
MY_MainController *mainController = [MY_MainController alloc];
mainController = [mainController init];
MY_ServiceManager *serviceManager = [MY_ServiceManager alloc];
serviceManager = [serviceManager init];
MY_BasicAccountService *accountService = [MY_BasicAccountService alloc];
accountService = [accountService init];
id<MY_AccountDAO> accountDAO = [[MY_FileSystemAccountDAO alloc] init];
[accountService setAccountDAO:accountDAO];
serviceManager.accountService = accountService;
return mainController;
}
@end
@interface MY_FileSystemAccountDAO
@interface MY_FileSystemAccountDAO : MY_FileSystemDAO <MY_AccountDAO>
@end
@interface MY_BasicAccountService
#import <Foundation/Foundation.h>
#import "MY_BasicService.h"
#import "MY_AccountService.h"
@interface MY_BasicAccountService : MY_BasicService <MY_AccountService>
- (void) setAccountDAO:(id<MY_AccountDAO> *)accountDAO;
@end
答案 0 :(得分:0)
- (void) setAccountDAO:(id<MY_AccountDAO> *)accountDAO;
该行声明accountDAO
是指针的指针,因为id
隐式是指针。正确的声明只是
- (void) setAccountDAO:(id<MY_AccountDAO>) accountDAO;