Xcode 警告信息处理:Format string is not a string literal (potentially insecure)

来源:互联网 发布:pp软件2015下载 编辑:程序博客网 时间:2024/05/21 06:54
NSObject *obj = @"A string or other object.";NSLog([NSString stringWithFormat:@"%@",obj]);// 有警告NSLog([NSString stringWithFormat:@"%@",obj],nil);// 解决方案

为何如此?


解答=>上面可以直接写成:

NSLog(@"A string or other object.");//或者NSObject *obj = @"A string or other object.";NSLog(@"%@",obj);//没有必要再调用 NSString的 stringWithFormat: 方法


文章出处:http://www.oschina.net/question/54100_33881
===============================================================

注:警告信息:“Format string is not a string literal (potentially insecure)”说明NSLog要求的参数为字面量,不可为NSString* 类型,如:

NSString* s=...;NSLog(s) //警告//-------------------------NSLog([NSString stringWithFormat...]);//依旧警告


0 0
原创粉丝点击