Format String不是文字字符串(可能不安全)警告 [英] Format String is not a literal string (potentially insecure) warning

查看:1494
本文介绍了Format String不是文字字符串(可能不安全)警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

警告:格式不是字符串文字,没有格式参数

我的应用程序中有以下代码行,供开发人员使用。我正在学习Objective C的基础知识,当我更新App兼容iPhone 5时,我看到以下警告(我没有更改他的代码)Format String不是文字字符串(可能不安全)。代码如下;

I have the following line of code that is in my app that a Developer worked on. I am learning the basics of Objective C and as I was updating the App to be iPhone 5 compatible, I see the following warning (I did not change his code) Format String is not a literal string (potentially insecure). The code is as follows;

self.progressHud.labelText = [NSString stringWithFormat:message];   

我不知道这意味着什么,也不想上传任何可能的内容安全问题或被Apple拒绝。大家都非常感谢您的帮助。

I don't know exactly what this means and don't want to upload anything that can either be a security issue or get rejected by Apple. Any and all help is appreciated from you all.

推荐答案

使用以下行:

self.progressHud.labelText = [NSString stringWithFormat:@"%@", message]; 

在目标C中,此行从任何格式(如int,float等)获取值以显示标签。因为UILabel和IBOutlet元素仅显示NSString值。

In objective C, this line get the values from any format such as int,float etc to display the Label. because UILabel and IBOutlet Elements only display the NSString values.

但是,如果您不需要创建包含多个变量的字符串,那么简单地使用它会更有效:

However, if you don't need to create a string with multiple variables, it would be more efficient to simply use:

self.progressHud.labelText = message;   

这篇关于Format String不是文字字符串(可能不安全)警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆