好的,好像 SDK 没有为我提供任何我可以用来检查 EKEvent 是否为只读的东西。我通过创建一个将“isReadOnly”方法添加到所有 EKEvent 实例的类别来创建一个解决方法。
EKEvent+ReadOnlyCheck.h
@interface EKEvent(ReadOnlyCheck)
- (BOOL) isReadOnly;
@end`
EKEvent+ReadOnlyCheck.m
#import "EKEvent+ReadOnlyCheck.h"
@implementation EKEvent(ReadOnlyCheck)
- (BOOL) isReadOnly {
BOOL readOnly;
NSString *originalTitle = [self.title retain];
NSString *someRandomTitle = [NSString stringWithFormat:@"%i", arc4random()];
self.title = someRandomTitle;
readOnly = [originalTitle isEqualToString:self.title];
self.title = originalTitle;
[originalTitle release];
return readOnly;
}
@end
当上述文件到位后,我可以简单地调用isReadOnly
我选择的 EKEvent。
#import "EKEvent+ReadOnlyCheck.h"
...
if ([event isReadOnly]) {
// Do your thing
}
...