1
votes

This is my first post to SO, so I'll get right to it.

I'm working on a calendar application and I'm trying to figure out how to add new functionality to EKEvents. I've done enough research to know that the EKEvent class isn't really meant to be subclassed as it will lose any data if cast and forced into the eventstore.

Is there any way to accomplish adding new functionality to the EventKit objects?

Maybe be able to subclass the EKEventStore along with EKEvent so that they work together? Or maybe you just have to create a separate database which would store pointers to the events along with whatever new data (or something along those lines)?

Any ideas are much appreciated! Thanks in advance!

1

1 Answers

0
votes

You don't have to necessarily create a subclass in Objective-C when you want to extend its functionality.

If you want to add a method to the EventKit class you should use categories. An example would be:

  1. Create a new Objective-c .h and .m file named BaseClass+Category.h and BaseClass+Category.m
  2. Implement your method on them
  3. Use the method anywhere you have an EventKit Object

[code]

//BaseClass+MyMethod.h
#import "BaseClass.h"

@interface BaseClass (MyMethod)

- (void) myMethodImplementation;

@end

//BaseClass+MyMethod.m
#import "BaseClass+MyMethod.h"

@implementation BaseClass (MyMethod)

- (void) myMethodImplementation { }
@end

//In Your Code Somewhere
BaseClass *object = [[BaseClass alloc] init];
[object myMethodImplementation];

[/code]