&引用;可能不响应';initWithStyle:'&引用;Xcode 4.2中的警告

&引用;可能不响应';initWithStyle:'&引用;Xcode 4.2中的警告,xcode,warnings,xcode4.2,Xcode,Warnings,Xcode4.2,我快乐地使用课堂已经有一段时间了。但自从升级到Xcode 4.2后,我收到了以下警告: 'CPLockController' may not respond to 'initWithStyle:' 无论代码中的哪一行: CPLockController *lockController = [[CPLockController alloc]initWithStyle:(UITableViewStyle)CPLockControllerTypeAuth]; CPLockController.m文

我快乐地使用课堂已经有一段时间了。但自从升级到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中创建了一个问题,但到目前为止还没有回复


请引导。。。谢谢

这是因为开发人员没有在类声明中声明
-initWithStyle:
。如果检查,则不存在
-initWithStyle:

我不确定开发人员为什么没有这样做(可能他忘记了,在这种情况下,您应该提交一个bug),但是您可以很容易地将声明添加到CPLockController.h,如下所示:

@interface CPLockController : UIViewController <UITextFieldDelegate> {
    // Bunch of ivars
}

// Bunch of properties

- (void)setTitle:(NSString *)title;
- (id)initWithStyle:(CPLockControllerStyle)theStyle; // <-- add this line
@end
@接口CPLockController:UIViewController{
//一串IVAR
}
//一串属性
-(void)setTitle:(NSString*)标题;

-(id)initWithStyle:(CPLockControllerStyle)theStyle;//谢谢。。。但现在警告更改为
警告:从枚举类型“UITableViewStyle”隐式转换为不同的枚举类型“CPLockControllerStyle”[-Wconversion,3]
@Tajar,这是因为您已显式将其强制转换为
(UITableViewStyle)
。去掉那个石膏,谢谢!超级专家帮助超级noob!