-2
我已經從示例項目中複製下面的代碼,但收到警告「格式字符串未使用數據參數」。在我從中複製的項目中,它在每個報價/條目的末尾添加了一個隨機數。我不需要這個,並且想象這與它有關。編譯器警告:格式字符串不使用數據參數
任何人都可以告訴我如何解決?
dvent
(IBAction)button:(id)sender {
int r = arc4random() % 2;
NSString *text;
switch (r) {
case 1:
text = [NSString stringWithFormat: @"The rain in spain falls mainly on the plain", r];
break;
case 2:
text = [NSString stringWithFormat: @"I think therefore I am", r];
break;
}
self.label.text = text;
這與Xcode無關。 –
閱讀錯誤。然後看看你對'stringWithFormat:'的調用。這很清楚。 – rmaddy
另外,*閱讀該方法的文檔*。 –