2013-03-12 65 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

相关问题