Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
[NSDateComponents setTimeZone:] 函数在 iOS 3.1 中崩溃,给出 NSInvalidArgumentException。但它在更高的 iOS 版本上运行良好。有没有人对此有解决方案?提前致谢。
此方法(公开)仅从 4.0 操作系统开始可用,因此您不得在 3.x 操作系统上调用该方法 - 在调用它之前执行运行时检查 NSDateComponent 实例是否响应选择器:
NSDateComponents* comps = ...; if ([comps respondsToSelector:@selector(setTimeZone:)]) [comps setTimeZone:zone];