2011-08-15 5 views
0

목표 C를 처음 사용하기 때문에 바보 같은 질문 인 경우 사과드립니다. 다음 코드에서이 오류가 발생합니다. 내가 전역 변수경고 : 'setOn :'인수 1을 전달하면 캐스트가없는 포인터에서 정수가됩니다.

//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을 사용하고

나는 recurringBool이 정수가 아닌 나는 이러한 오류를 받고 있어요 이유를 모르겠어요. 그래서 나는 그것을 잘못 사용하고 있다고 가정해야합니다. 어떤 도움이라도 대단히 감사하겠습니다.

답변

6

* BOOL 선언에서 *를 제거하십시오. BOOL은 포인터가 아닙니다.

+0

그게 전부 였어! 불충분 한 질문에 대해 유감스럽게 생각하며 다른 사람들에게 도움이되기를 바랍니다. – SurferJoe

+0

향후 독자를 돕고 Nathianal 학점을 부여하려면이 답을 올바른 것으로 표시하십시오. –

0

BOOL은 기본 유형이며 이 아니며 Objective-C 객체입니다. 일반적으로 포인터가 아닌 int 또는 float과 같이 원시 코드를 사용합니다. 따라서 BOOL *recurringBool; 대신 BOOL recurringBool;을 선언하십시오.

관련 문제