NSDateComponents setTimeZone NSInvalidArgumentException at iOS 3.1
[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];
精彩评论