2011-08-15 24 views
0

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を使用しています。だから私はそれを間違って使用していると仮定しなければなりません。どんな助けでも大歓迎です。

答えて

6

*をBOOL宣言から削除してください。 BOOLはポインタではありません。

+0

それでした!不明な質問に申し訳ありませんが、これが他の人に役立つことを願っています。 – SurferJoe

+0

将来の読者を助け、Nathianalのクレジットを与えるために、この回答を正しいとマークしてください。 –

0

BOOLは、プリミティブ型であり、ではありません。 Objective-Cオブジェクトです。通常はポインタを使用するのではなく、intまたはfloatのようにそのまま使用します。したがってBOOL *recurringBool;ではなくBOOL recurringBool;を宣言してください。

関連する問題