I have been having a bit of trouble sublclassing the EKEvent
Class. The scenario is this, I am pulling all my events from an external database using a webservice, so all the events come with an ID. I then want to put these events into the device calendar and retrieve them later. The problem is, when I retrieve the event I need it to have the same id as the event on the server so I can do a quick look up to get additional info on the event.
I am aware that the identifier
property of EKEvent
is read only, hence the reason I want to create a subclass of the class where I can add an additional property called something like myid
and store the id of the event (the one from the server) with it in the eventstore. I have tried to create a subclass and everything seems to work fine and compiles, but on runtime I get an error when I try to set the extra eventid proporty that I add in the subclass, the error message is:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[EKEvent setEventId:]: unrecognized selector sent to instance 0x83c0770'
This is some test code I use to create the event from my EKEvent
subclass:
SectureEvent *myEvent = (SectureEvent*)[EKEvent eventWithEventStore:eventDB];
myEvent.title = self.evento;
myEvent.startDate = [[NSDate alloc] init];
myEvent.startDate = [NSDate date];
myEvent.endDate = [[NSDate alloc] init];
myEvent.endDate = [[NSDate alloc] init];
myEvent.allDay = YES;
myEvent.eventId = self.eventId;
The error occurs on the last line myEvent.eventId = self.eventId;
and app crashes. So my question essentailly if I can effectively subclass the EKEvent
class and if so what am I doing wrong here?
Thanks in advance!