2013-03-12 46 views
-1

在我的模型中,我有一個通知屬性,負責更新控制器,如果我有匹配的卡片或卡片不匹配。因此,在檢查匹配(模型)後,我獲得了比賽的2張卡的方法我寫這行:當試圖發送stringWithFormat到NSString時發出警告

self.notification = [NSString stringWithFormat:@"%@ matched to %@", card.contents, otherCard.contents]; 

通知只讀屬性。

@property (readonly, nonatomic) NSString *notification; 

答控制器心中已經寫了這行:

self.notificationLabel.text = [NSString stringWithFormat:self.game.notification];

現在,它完美的作品,但我得到一個警告:

format string is not a string literal (potentially insecure), why is that?

+0

這裏有很多重複的,實際上:http://stackoverflow.com/search?q=format+string+is+not+literal+%5Bobjective-c%5D – 2013-03-12 00:10:18

回答

0

明白了,我不需要使用stringWithFormat,只需stringWithString(在控制器中),因爲notification是一個NSString對象。

+2

你不需要'stringWithString :「要麼。你應該這樣做:'self.notificationLabel.text = self.game.notification;'。 – rmaddy 2013-03-12 00:19:46

+0

哦,好的,謝謝:) @rmaddy – JohnBigs 2013-03-12 00:55:37

相關問題