开发者

NSDateComponents setTimeZone NSInvalidArgumentException at iOS 3.1

开发者 https://www.devze.com 2023-01-31 05:59 出处:网络
[NSDateComponents setTimeZone:] function crashes at iOS 3.1, gives开发者_如何转开发 NSInvalidArgumentException. but it works fine at higher iOS versions. Is there anyone who has a solution for this?

[NSDateComponents setTimeZone:] function crashes at iOS 3.1, gives开发者_如何转开发 NSInvalidArgumentException. but it works fine at higher iOS versions. Is there anyone who has a solution for this? thanks in advance.


This method is (publicly) available starting 4.0 OS only so you must not call that method on 3.x OS - perform run-time check if NSDateComponent instance responds to selector before calling it:

NSDateComponents* comps = ...;
if ([comps respondsToSelector:@selector(setTimeZone:)])
    [comps setTimeZone:zone];
0

精彩评论

暂无评论...
验证码 换一张
取 消