Rashid
Rashid

Reputation: 804

NSCalendar calendarWithIdentifier throwing error on ios 7

I am creating my app with Xcode 6 and it works fine on ios8. I just tested the app on ios7 and i get this error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSCalendar calendarWithIdentifier:]: unrecognized selector sent to class 0x3a78418c

This is the code i am using as part of converting dates from Gregorian calendar to Persian Calendar:

NSCalendar *calendar = [NSCalendar calendarWithIdentifier:@"persian"];

Upvotes: 2

Views: 1703

Answers (2)

Martin R
Martin R

Reputation: 539765

The +[NSCalendar calendarWithIdentifier] class method is only available on iOS 8/OS X 10.9 and later.

But you can use the designated initializer method instead, this works on all iOS releases:

NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:@"persian"];

Upvotes: 8

Adi Pop
Adi Pop

Reputation: 226

It is supposed to work from iOS 8.

+ (NSCalendar *)calendarWithIdentifier:(NSString *)calendarIdentifierConstant NS_AVAILABLE(10_9, 8_0);

Upvotes: 1

Related Questions