警告:传递'setOn:'的参数1使指针中的整数不带强制转换

时间:2011-08-15 15:35:17

标签: iphone objective-c ios ipad ios4

我是Objective C的新手,所以如果这是一个愚蠢的问题我会道歉。我在以下代码中收到此错误。

我使用recurringBool作为全局变量

//Declared in the AppDelegate.h
extern BOOL *recurringBool;

//Defined in the AppDelegate.m
BOOL *recurringBool;

// In another class this method sets recurringBool
- (IBAction)MakeRecurring:(id)sender {
    UISwitch *Switch = (UISwitch *)sender;
    //this is where the 1st error is occurring. aNetS is a UISwitch
    recurringBool = Switch.on;
        **//warning: assignment makes pointer from integer without a cast**
}

//And in another method aNetS is set to recurringBool;
//this is where the second error is occurring. aNetS is a UISwitch
aNetS.on = recurringBool;
    //warning: passing argument 1 of 'setOn:' makes integer from pointer without a cast

我不确定为什么我会收到这些错误,因为recurringBool不是整数。所以我必须假设我错了。任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:6)

从BOOL声明中删除*。 BOOL不是指针。

答案 1 :(得分:0)

BOOL是基本类型,不是 Objective-C对象。您通常使用它,例如intfloat,而不是通过指针。因此,请声明BOOL recurringBool;而不是BOOL *recurringBool;