“可能不会响应“initWithStyle:”” Xcode 4.2 中的警告
我已经愉快地使用 CPLockController 类有一段时间了。但自从升级到 Xcode 4.2 后,我一直收到以下警告:
'CPLockController' may not respond to 'initWithStyle:'
无论代码中的这一行是:
CPLockController *lockController = [[CPLockController alloc]initWithStyle:(UITableViewStyle)CPLockControllerTypeAuth];
CPLockController.m 文件中的实现是:
- (id)initWithStyle:(CPLockControllerStyle)theStyle {
if(self == [super init]){
self.style = theStyle;
self.retry = NO;
self.tempString = [NSMutableString string];
self.hideCode = YES;
}
return self;
}
CPLockControllerStyle 的类型定义:
typedef enum {
CPLockControllerTypeAuth,
CPLockControllerTypeSet
} CPLockControllerStyle;
我什至在 github 中创建了一个问题,但没有回复到现在为止!
请指导...谢谢!
I have been using CPLockController Class happily for quite a while. But since upgraded to Xcode 4.2, I have been getting the following warning:
'CPLockController' may not respond to 'initWithStyle:'
wherever this line is in the code:
CPLockController *lockController = [[CPLockController alloc]initWithStyle:(UITableViewStyle)CPLockControllerTypeAuth];
The implementation in CPLockController.m file is:
- (id)initWithStyle:(CPLockControllerStyle)theStyle {
if(self == [super init]){
self.style = theStyle;
self.retry = NO;
self.tempString = [NSMutableString string];
self.hideCode = YES;
}
return self;
}
and type definition of CPLockControllerStyle:
typedef enum {
CPLockControllerTypeAuth,
CPLockControllerTypeSet
} CPLockControllerStyle;
I even created an issue in github, but no reply up till now!
Please guide... thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为开发者没有在类声明中声明
-initWithStyle:
。如果您检查 CPLockController.h,-initWithStyle:
不存在。我不确定为什么开发人员没有这样做(也许他忘记了,在这种情况下你应该提交一个错误),但你可以轻松地将声明添加到 CPLockController.h 中,如下所示:
That’s because the developer hasn’t declared
-initWithStyle:
in the class declaration. If you inspect CPLockController.h,-initWithStyle:
is not there.I’m not sure why the developer hasn’t done this (maybe he’s forgotten it, in which case you should file a bug), but you can easily add the declaration to CPLockController.h as follows: