我有这段运行良好的代码,但我不知道这是否是调用 stringWithFormat 的正确方法,因为在文档中 %d 代表 int 并且我传递了一个 long:
long seconds = (long)[[NSDate date]timeIntervalSince1970];
NSString *unixTimestamp = [NSString stringWithFormat:@"date=%d", seconds];
提前致谢!
Try %ld
:
NSString *unixTimestamp = [NSString stringWithFormat:@"date=%ld", seconds];
摘要来自printf文档(NSString的stringWithFormat格式遵循与printf函数相同的标准):
l (ell)
指定以下 d、i、o、u、x 或 X 转换
说明符适用于 long 或 unsigned long 参数
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)