我是新來的Objective C,所以我很抱歉如果這是一個愚蠢的問題。我在下面的代碼中得到這個錯誤。警告:傳遞'setOn:'的參數1使得指針中的整數沒有投射
我使用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不是整數。所以我必須假設我錯了。任何幫助將不勝感激。
就是這樣!對不起,我希望這可以幫助別人。 – SurferJoe
標記此答案正確,以幫助未來的讀者,並給予Nathianal信用。 –