我有一个自定义 NSObject 类,我在其中声明了以下属性和函数。
@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;
在我的 .m 中,我执行以下操作。
+(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;
}
我通过以下方式添加新约会。
[appointments addObject:[Appointment AppointmentNamed:event.title
dateTime:dateString
date:event.endDate
event:event]];
但是当我这样做时,我得到一个抱怨的错误-[EKEvent copyWithZone:]:
有人可以帮我吗?
亲切的问候。