- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我遇到了问题。我需要知道我的 EventStore 中的事件何时更改,因此对于这种情况,我使用 EKEventStoreChangedNotification
但此通知返回给我的是 userInfo
中难以理解的字典它看起来像这样:
EKEventStoreChangedObjectIDsUserInfoKey = ("x-apple-eventkit:///Event/p429" );
我不知道如何使用这些数据来访问已更改的对象。请帮助我
最佳答案
这将检测更改的事件并记录日期范围内的事件标题。虽然,我最终没有这样做,因为实际上我不知道日期范围。我需要与我正在处理的所有事件进行比较,这意味着我无论如何都需要刷新它们,因为对象 ID 可能已更改。这最终使每个事件都没有那么有用,现在我只是在发生变化时每隔几秒钟刷新一次并忽略细节。我希望 Apple 改进这些通知。
#pragma mark - Calendar Changed
- (void)calendarChanged:(NSNotification *)notification {
EKEventStore *ekEventStore = notification.object;
NSDate *now = [NSDate date];
NSDateComponents *offsetComponents = [NSDateComponents new];
[offsetComponents setDay:0];
[offsetComponents setMonth:4];
[offsetComponents setYear:0];
NSDate *endDate = [[NSCalendar currentCalendar] dateByAddingComponents:offsetComponents toDate:now options:0];
NSArray *ekEventStoreChangedObjectIDArray = [notification.userInfo objectForKey:@"EKEventStoreChangedObjectIDsUserInfoKey"];
NSPredicate *predicate = [ekEventStore predicateForEventsWithStartDate:now
endDate:endDate
calendars:nil];
// Loop through all events in range
[ekEventStore enumerateEventsMatchingPredicate:predicate usingBlock:^(EKEvent *ekEvent, BOOL *stop) {
// Check this event against each ekObjectID in notification
[ekEventStoreChangedObjectIDArray enumerateObjectsUsingBlock:^(NSString *ekEventStoreChangedObjectID, NSUInteger idx, BOOL *stop) {
NSObject *ekObjectID = [(NSManagedObject *)ekEvent objectID];
if ([ekEventStoreChangedObjectID isEqual:ekObjectID]) {
// Log the event we found and stop (each event should only exist once in store)
NSLog(@"calendarChanged(): Event Changed: title:%@", ekEvent.title);
*stop = YES;
}
}];
}];
}
关于ios - 如何检测更改了哪个 EKevent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16162027/
EKEvent 从我的应用程序以编程方式创建,当我获取在 iPhone 日历中创建的 EKEvent 时,我如何识别由 iPhone 日历或我创建的两个 (EKEvent) 事件 最佳答案 您可以做很
我将周期性事件 (EKEvent) 写入日历中。如何获取并修改特定日期内的这些重复事件之一? 事件是通过以下代码创建的: + (void) writeTestEvent{ EKEventSto
我正在使用 Xcode 6.0.1,使用 Event Kit 制作测试应用。以下代码成功地填充了每个事件的标题,但即使 hasNotes 属性返回 YES,其注释也会返回为 (null)。而且,我可以
我正在尝试创建一个具有查看日历事件的功能的应用程序。我能够读取所有属性,但EKAlarm遇到问题。当我在for循环中执行NSLog时,它确认它应该达到15分钟的警报日志,但它正在传递。 for (in
我正在 iOS5 中开发 EKEvent。我可以添加、删除、列出事件,但现在的问题是当我尝试编辑现有事件时,“完成”按钮会产生问题。它不会进入 eventEditViewController: 方法。
我的应用程序中有一个功能可以将事件添加到日历中,该过程涉及解析日期的字符串表示形式(使用夏令时调整,并将 EKEvent startDate 设置为它,这里是一个片段: let eventStore
在我的应用程序中,我正在向设备日历添加一个事件。我正在这样做 if ([db.saveCalenderSettings isEqualToNumber:[NSNumber numberWithBool
我正在开发一个日历应用程序,我们可以在其中查看 iCal 中的所有事件。在应用程序中,我们可以选择取消事件。如果事件被取消,那么我们需要更改事件的状态。但是 EKEvent 的状态属性是只读的,所以当
我正在尝试为项目制作事件同步功能。我需要与远程服务器同步事件。 假设我在设备 A 中安装了该应用。 如果我登录到另一台设备让 B,那么从 A 同步的事件也应该出现在设备 B 中,并且 B 的事件也应该
我们如何从 iPhone 日历事件中获取旅行时间。 我指的是我们将在创建事件时输入的旅行时间。 我将使用“EKEventStore”获取所有事件详细信息。 最佳答案 毕竟我得到了解决方案。 EKEve
NSDictionary *d = (NSDictionary *) [arrGarden objectAtIndex:0]; int intarrCount=0; NSString
我遇到了问题。我需要知道我的 EventStore 中的事件何时更改,因此对于这种情况,我使用 EKEventStoreChangedNotification 但此通知返回给我的是 userInfo
我一直在测试此代码以将日历添加到 IOS Cal 应用程序,并将一些事件添加到应用程序中的特定日历。 我有一个装有 IOS7 的 Ipad,禁用了 iCloud。 第一个问题是当我创建日历时,我在 i
我在我的应用程序中使用 Kal 日历(希望它不会改变太多)但我从中获得了一个 EKEvent 对象,具体取决于用户在日历上的选择。 无论如何,如何编辑和删除已经存在的事件?即我收到的 EKEvent?
我在 Xcode 9、iOS11 上保存 EKEvent 时遇到此 NSInternalInconsistencyException 错误。 do { try eventStore.save
我想创建一个 EKEventStore 对象,并在不同的类中使用它,我可以在每个类中使用不同的实例吗?或者我必须使用单例模式创建一个 EKEventStore 实例? Apple 文档建议创建一个实例
在我的应用程序中,我显示 EKEvents 列表,我想在 UITableView 中显示一个月的所有事件,每个部分包含各自的日期。嗯,这可行,我得到了我需要的所有数据,但获取速度非常慢。 问题在于事件
背景信息 我有一个包含 NSDate 对象的类,该对象用作 EKEvent 的日期。 EKEvent 添加到日历中,有时会设置 EKRecurrenceRule,其日期比事件的实际日期早 x 天。例如
一种解决方案可能是: 创建一个新模型 EKEventExt 并在它们之间添加一对一关系,我不确定它是否可行,因为 EKEventExt 存储在我的模型中sqlite 和 EKEvent 存储在 eve
我正在为日历设置事件。该代码可以正常工作,但我会检查我的设备日历上是否设置了事件。它没有显示任何内容。我在 ios6 中这样做,当我在 ios5 中这样做时,它工作正常。 最佳答案 这对我有用,你也可
我是一名优秀的程序员,十分优秀!