0

I have a custom NSObject class where I declare the following attributes and functions in it.

@property (nonatomic, retain, readonly) NSDate *date;
@property (nonatomic, retain, readonly) NSString  *dateTime;
@property (nonatomic, retain, readonly) NSString *title;
@property (nonatomic, retain, readonly) EKEvent *event;

+(Appointment*)AppointmentNamed: (NSString *)title 
                       dateTime:(NSString *)dateTime
                           date:(NSDate *)date 
                          event:(EKEvent *)event;

-(id) initWithName:(NSString *)title 
          dateTime:(NSString *)dateTime 
              date:(NSDate *)date 
             event:(EKEvent *)event;

In my .m I do the following.

+(Appointment*)AppointmentNamed:(NSString *)aTitle
                       dateTime:(NSString *)aDateTime 
                           date:(NSDate *)aDate 
                          event:(EKEvent *)aEvent {
    return [[Appointment alloc]initWithName:aTitle
                                   dateTime:aDateTime 
                                       date:aDate 
                                      event:aEvent];
}
-(id)initWithName:(NSString *)aTitle 
         dateTime:(NSString *)aDateTime 
             date:(NSDate *)aDate 
            event:(EKEvent *)aEvent{
    if((self = [super init])){
        date = [aDate copy];
        dateTime = [aDateTime copy];
        title = [aTitle copy];
        event = [aEvent copy];

    }
    return self;
}

I add a new appointment in the following way.

[appointments addObject:[Appointment AppointmentNamed:event.title 
                                             dateTime:dateString 
                                                 date:event.endDate 
                                                event:event]];

But when I do this I get an error that is complaining about -[EKEvent copyWithZone:]:

Can anybody help me with this?

Kind regards.

CRDave
  • 9,279
  • 5
  • 41
  • 59
Steaphann
  • 2,797
  • 6
  • 50
  • 109
  • just a wild guess but have you tried naming your property somthing other than .event? See these 2 questions: [Question 1](http://stackoverflow.com/questions/6644522/something-copywithzone-unrecognized-selector-sent-to-instance-when-using-b) [Question 2](http://stackoverflow.com/questions/10784207/uilabel-copywithzone-unrecognized-selector-sent-to-instance) – jhilgert00 Feb 06 '13 at 12:17

2 Answers2

0

The availability setting for the event. This setting is used by CalDAV and Exchange servers to indicate how the event should be treated for scheduling purposes.If the event’s calendar does not support availability settings, this property’s value is EKEventAvailabilityNotSupported.

See this link EKEventAvailability and also this one EKEvent

i hope this helpful to you...

Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
  • @Pras Joshi, thank you for your answer but changing (nonatomic, retain, readonly) to (readwrite, retain) did the trick! – Steaphann Feb 06 '13 at 12:25
0

you can copy only object which have implemented the NSCopying protocol (e.g. NSDate). EKEvent doesn't have implemented the NSCopying protocol so you can't create a EKEvent instance by using copy. May it's useful to make the event property readwrite so you mustn't use copy.

Areal-17
  • 406
  • 3
  • 10