簡體   English   中英

為什么 Xcode 告訴我這個變量未聲明?

[英]Why is Xcode telling me this variable is undeclared?

我在Xcode中遇到以下錯誤,我知道我需要聲明filteredChildren所以我嘗試將NSArray *filteredChildren行添加到頭文件中,但這只會讓事情變得更糟。 我需要將哪些代碼添加到 delcare filteredChildren的標頭中?

替代文字 http://snapplr.com/snap/wkd6

您的標題應該看起來像這樣:

@interface SomeClass {
    NSArray *filteredChildren; // this should fix the compiler error
}

// If the filteredChildren method is public, add this declaration as well to prevent compiler warnings
- (NSArray *)filteredChildren;

@end

看不到代碼,但要確保在函數之后打開和關閉所有大括號,知道這可能會導致問題,並且可以輕松完成大型項目。

int a = 1;
void example () 
{ if (exampleVar = 1 {
a = 2; // not declared error
}


int a = 1;
void example () 
{ if (exampleVar = 1 {
a = 2; // should be declaring
}
}

檢查所有頭文件和類層次結構以確保您沒有兩次聲明頭文件或同一個類,這會在您創建類的實例並使其未聲明時產生影響。

如果不是這種情況,請嘗試清理/重置您的編譯數據。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM