gpt4 book ai didi

objective-c - 格式字符串不是字符串文字(可能不安全)

转载 作者:太空狗 更新时间:2023-10-30 03:44:33 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Why is my string potentially unsecure in my iOS application?

将 XCode 升级到 4.6 后的新编译器警告:

Format string is not a string literal (potentially insecure)

展示最后两行警告的最小示例:

  for (NSUInteger i = 0; i < 10; i++) {
NSString *res = [testInstance generate:i];
NSString *desc = [NSString stringWithFormat:@"TestData: %d", i];
STAssertNotNil(res, desc);
STAssertNotEquals(@"", res, desc);
}

我查看了与此警告有关的其他问题,但它们源于程序员不必要地使用 stringWithFormat: - 这里我想要一个动态断言描述,它每次迭代都会更改,但不会每次检查更改。

我可以将格式字符串和数据传递到断言中,但我必须独立维护描述。

如果我需要先对描述进行格式化,然后再将其用于日志消息或断言调用中,我该如何避免此警告?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com