我是 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 不是整数。所以我必须假设我用错了。任何帮助将不胜感激。
最佳答案
从 BOOL 声明中删除 *。 BOOL 不是指针。
关于iphone - 警告 : passing argument 1 of 'setOn:' makes integer from pointer without a cast,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7066996/