解决Format string is not a string literal (potentially insecure)问题

简介: 在用宏实现部分字符串格式化问题时,stringWithFormat方法会出现【Format string is not a string literal (potentially insecure)】警告

问题


在用宏实现部分字符串格式化问题时,stringWithFormat方法会出现【Format string is not a string literal (potentially insecure)】警告

网络异常,图片无法展示
|

解决方法


添加一个格式化方式实现

/// 字符串格式化化
NSString *GetFormatStr(NSString *str, ...)
{
   va_list args;
   va_start(args, str);
   NSString *result = [[NSString alloc] initWithFormat:str arguments:args];
   va_end (args);
   return result;
}

网络异常,图片无法展示
|

目录
相关文章
|
7月前
|
SQL 数据库
【YashanDB 知识库】导入数据时报错:YAS-00008 type convert error:literal does not match format string
【YashanDB 知识库】导入数据时报错:YAS-00008 type convert error:literal does not match format string
|
7月前
|
SQL 数据库
【YashanDB知识库】导入数据时报错:YAS-00008 type convert error:literal does not match format string
【YashanDB知识库】导入数据时报错:YAS-00008 type convert error:literal does not match format string
C++11新特性探索:原始字符串字面值(raw string literal)
原始字符串字面值(raw string literal)是C++11引入的新特性。
299 0
|
C++
【洛谷 P1000】超级玛丽游戏 题解(raw string literal)
这是一个关于使用字符画展示超级玛丽场景的编程题。无需输入,输出为指定的马里奥图案。提供的C++代码直接打印了预设的场景图案。
143 0
|
C++
【洛谷 B2025】输出字符菱形 题解(raw string literal)
使用`*`构建一个斜置的、对角线长度为5的菱形。无输入要求。输出示例:`*`、`***`、`*****`、`***`、` *`。代码实现使用C++,直接打印预定义字符串完成。
232 0
|
安全
格式化字符串漏洞(Format String Attack)
格式化字符串漏洞(Format String Attack)
238 0
|
索引 Python
技巧 | 5000字超全解析Python三种格式化输出方式【% / format / f-string】
技巧 | 5000字超全解析Python三种格式化输出方式【% / format / f-string】
Python爬取中国最好大学排行榜报错TypeError: unsupported format string passed to NoneType.__format__
Python爬取中国最好大学排行榜报错TypeError: unsupported format string passed to NoneType.__format__
|
Python
Python格式字符串的三种方法你都掌握了吗,%s%d%f+format()+f-string,深度测评YYDS实至名归
Python格式字符串的三种方法你都掌握了吗,%s%d%f+format()+f-string,深度测评YYDS实至名归
249 0
Python格式字符串的三种方法你都掌握了吗,%s%d%f+format()+f-string,深度测评YYDS实至名归