OGeek|极客世界-中国程序员成长平台

标题: ios - 为什么只有当我的 iPhone 未连接到我的 Mac 时才会出现警告? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 08:46
标题: ios - 为什么只有当我的 iPhone 未连接到我的 Mac 时才会出现警告?

不是重复的,但警告信息是相同的。我读了这篇文章,但没有帮助。

performSelector may cause a leak because its selector is unknown

我没有使用 performSelector,但我收到的警告与使用时相同。

Xcode 6.3 中的警告信息是

 PerformSelector may cause a leak because its selector is unknown

代码是

NSString *string=[NSString stringWithFormat"%tu", data.length];
NSLog(@" Expected :%lli",[response expectedContentLength]);

data.length 应该返回一个 NSUInteger

expectedContentLength 是 long long

当我将 %tu 更改为 %zu 时,我收到一条新的警告消息

 Values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead



Best Answer-推荐答案


警告是关于 NSUInteger 大小的变化取决于 CPU 架构,并且可能仅在发布版本期间发生(我理解为“未连接到 Mac”),因为发布版本包含所有有效的 CPU 架构(32 位和 64 位),而调试版本仅包含用于调试的设备的架构。 (如果您没有更改默认设置的build设置,这是正确的)。

NSUInteger 改变大小时,假设它是 unsigned long 并使用强制转换:

NSString *string=[NSString stringWithFormat"%lu", (unsigned long)data.length];

关于ios - 为什么只有当我的 iPhone 未连接到我的 Mac 时才会出现警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31138931/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4