NSTimeInterval 用法
我有以下代码:
NSNumber *rowValue = [movieDescription objectAtIndex:film];
NSLog(@"ROWVALUE %@",rowValue);
NSUInteger converted = rowValue;
NSLog(@"UNIX %@",converted);
NSDate *date = [NSDate dateWithTimeIntervalSince1970:converted];
NSLog(@"TODAYS DATE %@",date);
这是输出到调试器控制台:
2011-03-24 14:55:37.330 ViRe[27540:307] ROWVALUE 1300906517
2011-03-24 14:55:37.332 ViRe[27540:307] UNIX 1300906517
2011-03-24 14:55:37.338 ViRe[27540:307] TODAYS DATE 1970-01-29 00:12:00 +0000
显然这是错误的,但我不明白如何/为什么?
有什么建议吗?谢谢
I have the following code:
NSNumber *rowValue = [movieDescription objectAtIndex:film];
NSLog(@"ROWVALUE %@",rowValue);
NSUInteger converted = rowValue;
NSLog(@"UNIX %@",converted);
NSDate *date = [NSDate dateWithTimeIntervalSince1970:converted];
NSLog(@"TODAYS DATE %@",date);
This is outputing to the debugger console:
2011-03-24 14:55:37.330 ViRe[27540:307] ROWVALUE 1300906517
2011-03-24 14:55:37.332 ViRe[27540:307] UNIX 1300906517
2011-03-24 14:55:37.338 ViRe[27540:307] TODAYS DATE 1970-01-29 00:12:00 +0000
Clearly this is wrong but I can't see how/why?
Any advice? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要将 NSNumber 转换为 NSUInteger,请使用 NSNumber 的 unsignedIntegerValue 方法,并使用 %u 而不是 %@ 来记录 NSUInteger(请参阅 字符串格式说明符):
To convert an NSNumber to NSUInteger, use NSNumber's unsignedIntegerValue method and to log an NSUInteger, use %u instead of %@ (see String Format Specifiers):