Hi all,
I'm trying to make a subclass of NSCalendar, but without much luck. I've tried two ways:
thorough categories. I can create a modified object and a test method that I added (not part of NSCalendar) works just fine, but overriden methods don't work - e.g. if I call dateFromComponents:, the NSCalendar method is apparently called, not what I wrote in the category definition
regular subclass. In this case I can't even create an instance: initWithCalendarIdentifier throws a _CFRequireConcreteImplementation exception. Initially I only had a couple of methods overriden in the subclass, but then I've overriden all of the (documented) NSCalendar methods - and the result is the same.
Is it even possible to subclass NSCalendar?
The reason I want to do it is to make repeating Local Notifications with non-standard repeat intervals. The default functionality allows Local Notifications to repeat every [calendar unit], but I need irregular intervals - e.g. I can emulate "every 15 minutes" notifications by creating 4 "every hour" notifications 15 minutes apart, but I need them to fire at, say T+20, T+22, T+24, T+44, T+46, T+66 minutes and so on (T is the start time) - the interval between notifications is 20 minutes, then 2 minutes, then 20 minutes again and so on.
I was hoping that, since UILocalNotification wants an NSCalendar (in repeatCalendar property) to calculate when to fire the next notification, I can achieve what I want by overriding, say, dateFromComponents to just return [NSDate dateWithIntervalSinceNow] with interval alternating between 20 and 2 minutes - but my cunning plan seems to have a major problem because of the inability to subclass NSCalendar.
Edit: This whole thing is needed for when the app is in the background. In the foreground I use timers, just like No one in particular suggests.