Objective c NSRunAlertPanel+;格式字符串不是字符串文字(可能不安全)

Objective c NSRunAlertPanel+;格式字符串不是字符串文字(可能不安全),objective-c,nsstring,Objective C,Nsstring,好的,我知道格式字符串不是字符串文字警告,但我不知道它为什么出现在NSRunAlertPanel上,定义是: 应用工具包外部集成器NSRunAlertPanel(NSString*标题,NSString *msgFormat、NSString*defaultButton、NSString*alternateButton、NSString*otherButton等)NS_格式函数(2,6) 报告错误时,我通常只在消息上传递error.localizedDescription, 例如: 但是在升级到

好的,我知道格式字符串不是字符串文字警告,但我不知道它为什么出现在NSRunAlertPanel上,定义是:

应用工具包外部集成器NSRunAlertPanel(NSString*标题,NSString *msgFormat、NSString*defaultButton、NSString*alternateButton、NSString*otherButton等)NS_格式函数(2,6)

报告错误时,我通常只在消息上传递error.localizedDescription, 例如:

但是在升级到xcode 5.1之后,我开始收到这样的警告

所以我试过这样的方法:

NSRunAlertPanel(@"error", [NSString stringWithFormat:@"%@", err.localizedDescription], @"OK", nil, nil);
情况也一样。
有人知道如何解决这个问题吗?

msgFormat
是消息格式字符串,应该是字符串文字。 必要的参数作为“变量参数列表”添加到
otherButton
之后。比如说

NSRunAlertPanel(@"error", @"%@", @"OK", nil, nil, err.localizedDescription);
           message format---^         arguments---^
NSRunAlertPanel 创建一个警报面板。(已弃用。请改用NSAlert。)

NSRunAlertPanel(@"error", @"%@", @"OK", nil, nil, err.localizedDescription);
           message format---^         arguments---^