简体   繁体   English

EKEventAttribute的自定义NSObject类

[英]custom NSObject class with EKEventAttribute

I have a custom NSObject class where I declare the following attributes and functions in it. 我有一个自定义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;

In my .m I do the following. 在我的.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;
}

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:]: 但是,当我这样做时,我得到一个抱怨-[EKEvent copyWithZone:]:

Can anybody help me with this? 有人可以帮我吗?

Kind regards. 亲切的问候。

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 . CalDAV和Exchange服务器使用此设置来指示应如何处理事件以进行计划。如果事件的日历不支持可用性设置,则此属性的值为EKEventAvailabilityNotSupported

See this link EKEventAvailability and also this one EKEvent 请参阅此链接EKEventAvailability以及此EKEvent

i hope this helpful to you... 我希望这对您有帮助...

you can copy only object which have implemented the NSCopying protocol (eg NSDate). 您只能复制已实现NSCopying协议的对象(例如NSDate)。 EKEvent doesn't have implemented the NSCopying protocol so you can't create a EKEvent instance by using copy. EKEvent尚未实现NSCopying协议,因此您无法使用copy创建EKEvent实例。 May it's useful to make the event property readwrite so you mustn't use copy. 可以将事件属性设置为可读写,这很有用,所以您不能使用copy。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM