我是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不是指针。