2011-10-18 46 views
2

當我建立下面的代碼時,我得到一個像「格式不是字符串文字和格式參數」的警告。格式不是字符串文字,也沒有格式參數objective c

NSString *items = [NSString stringWithFormat:@"%d",itemNumber[0]]; 

for (int i = 1; i < (_housesOwned[0] + 1); i++) 
{ 
    items = [items stringByAppendingFormat:[NSString stringWithFormat:@",%d", itemNumber[i]]]; 
} 

我收到了for循環內部的警告。

itemNumber是一個int數組。請幫忙。即使構建成功,我仍然有這樣的感覺可能會在未來陷入困境。

+0

可能的重複[警告:「格式不是字符串文字和沒有格式參數」](http://stackoverflow.com/questions/1677824/warning-format-not-a-string-literal-and-no-格式參數) –

回答

3

你做這一行

items = [items stringByAppendingFormat:[NSString stringWithFormat:@",%d", itemNumber[i]]]; 

items = [items stringByAppendingFormat:@",%d", itemNumber[i]]; 

items = [items stringByAppendingString:[NSString stringWithFormat:@",%d", itemNumber[i]]]; 

這不會給警告。沒有其他的。

相關問題