问题标签 [ekeventstore]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1937 浏览

objective-c - Can't obtain reference to EKReminder array retrieved from fetchRemindersMatchingPredicate

When I create an NSPredicate via EKEventStore predicateForRemindersInCalendars; and pass it to EKEventStore fetchRemindersMatchingPredicate:completion:^ I can loop through the reminders array provided by the completion code block, but when I try to store a reference to the reminders array, or create a copy of the array into a local variable or instance variable, both array's remain empty. The reminders array is never copied to them.

This is the method I am using, in the method, I create a predicate, pass it to the event store and then loop through all of the reminders logging their title via NSLog. I can see the reminder titles during runtime thanks to NSLog, but the local arrayOfReminders object is empty. I also try to add each reminder into an instance variable of NSMutableArray, but once I leave the completion code block, the instance variable remains empty.

Am I missing something here? Can someone please tell me why I can't grab a reference to all of the reminders for use through-out the app? I am not having any issues at all accessing and storing EKEvents, but for some reason I can't do it with EKReminders.

The eventStore getter is where I perform my instantiation and get access to the event store.

Lastly, just to show that I am initializing my remindersForTheDay instance variable using lazy instantiation.

I've read through the Apple documentation and it doesn't provide any explanation that I can find to answer this. I read through the Blocks Programming docs and it states that you can access local and instance variables without issues from within a block, but for some reason, the above code does not work.

Any help would be greatly appreciated, I've scoured Google for answers but have yet to get this figured out.

Thanks everyone!

Johnathon.

UPDATE:

I have since created a new app that does nothing but instance an event store, setup a table view, setup a KVO and updates the UI as per the recommendations provided. The code below is the app in its entirety. The UITableView is never updated with the reminders content. The app launches, and stares at me. The reloadData method invocation should eventually have the UI updated with the reminder data.

The reminder data exists in self.reminders, because my NSLog outputs that I have 372 objects in the array.

Lastly, if I touch the UITableView on the device, the app crashes with "'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'".

0 投票
2 回答
1931 浏览

ios - 使用 predicateForEventsWithStartDate:endDate:calendars 方法查找 EKEvents

predicateForEventsWithStartDate:endDate:calendars用来查找在给定 24 小时内发生的所有事件。我想要在这一天举行的所有活动。我正在努力处理跨越多天的事件——即从晚上 10 点开始,到“第二天”凌晨 2 点结束。

谓词查询在执行搜索时似乎只考虑日历事件的开始日期。它向我显示了在我指定的时间开始(然后结束)的事件,但不显示在该时间段之前开始但随后泄漏到其中的事件。

我可以提前设置开始日期,然后删除在今天开始之前结束的事件。

Apple Docs 并不是特别有见地:

0 投票
0 回答
2086 浏览

ios - 如何在 iOS 中制作自定义日历并将其添加到默认应用程序?不能直接初始化日历。使用 calendarWithEventStore

我使用的是Apple 示例代码中的日历代码。

我想在应用程序中制作我的日历以添加事件。但我不知道如何制作自己的日历并将其添加到 iOS 的默认日历应用程序中。

我收到这个错误。 “由于未捕获的异常'NSGenericException'而终止应用程序,原因:'无法直接初始化日历。使用 calendarWithEventStore”

* - - 编辑 - - **

使用: self.defaultCalendar = [EKCalendar calendarForEntityType:EKEntityTypeEvent eventStore:self.eventStore]; 在添加事件和委托调用时

if (self.defaultCalendar == thisEvent.calendar) { 永远不会是真的。

请帮忙。

0 投票
0 回答
622 浏览

iphone - 目标 c 使用 ekevent 存储从日历中删除所有未来事件

我正在使用此方法删除 iphone 应用程序中的某些特定事件,使用 EKEventStore

[eventstore removeEvent:event span:EKSpanFutureEvents commit:YES error:&err];

但现在我的要求发生了变化,现在我必须从当前日期删除所有创建的事件,例如如果今天是 2013 年 7 月 2 日,那么我必须从 2013 年 7 月 2 日删除所有未来创建的事件。我正在尝试这样做,

但我没有得到想要的结果。请。指导我有关此thanx 并问候Saad。

我正在使用 ios sdk 6.1 在 xcode 4.5 中工作。

0 投票
0 回答
559 浏览

ios - EKEventStore 新事件创建似乎不起作用,也没有错误描述

我正在使用以下两种方法在设备日历中创建事件,事件是我的 managedObject 类。

我的事件已成功保存,并且我在设备日历上也看到了它们,但事件发生在 2001 年,并且在事件列表中进行了一些滚动后,事件消失了。在这方面需要帮助。

0 投票
1 回答
609 浏览

ios - 如何将 EKEvent 标记为已完成?

如何让用户将 EKEvent 标记为完成?我目前正在获取某个日期的事件并将其显示在 UITableView 中。

我希望用户点击事件单元以将其标记为完成。

可以更改什么(任何标签或布尔值)来更新和保存该 EKEvent 以在将来将其显示为完整事件?

我探索了

event.status, event.refresh, event.organizer, event.availability, etc.

但没有一个有用。

EKEventAvailability我试过

但它没有更新和返回 -1 ( EKEventAvailabilityNotSupported) 和更新。

请推荐!!

谢谢!

0 投票
2 回答
746 浏览

ios - 处理 EKEventStoreChangedNotification 通知

我在我的应用程序中列出事件。用户可以创建、编辑和删除事件。在viewDidLoad方法中,我获取我需要的所有事件并将它们推送到一个数组中。它按预期工作。

EKEventEditViewController对于我使用的创建、编辑和删除事件EKEventViewController,效果很好。在控制器的委托方法中,我对数组进行了我需要的更改并重新加载我的视图。

当然,如果用户从另一个应用程序(如内置日历应用程序)进行一些更改,我也想知道和处理。所以我观察EKEventStoreChangedNotification。从该通知中,我只得到“发生了变化”,而不是哪个事件或来自哪个应用程序。实际上我想知道的是,我的应用程序或其他应用程序是否发生了更改,以及哪些事件已更改。由于我已经在 EKEventEditViewControllerDelegate 方法中处理了更改(来自我的应用程序),因此我不需要再次处理它们。

如果我不知道哪些对象已更改,我必须对所有对象进行获取和排序。

现在我在日历(开发设备)中只有 5 个事件,当然获取和排序所有事件不是问题,但是如果用户有超过 1000 个,那么可能只有一个事件更改就过分了。

所以我的问题是:如何处理EKEventStoreChangedNotification

0 投票
2 回答
3254 浏览

iphone - iOS:EKEventStore 来源/defaultCalendarForNewEvents/calendarsForEntityType 在授权后均不返回任何内容

我有一个应用程序,我正试图帮助走出门。这段代码最初是由另一个团队使用 iOS5 编写的。我添加了成功运行的 requestAccessToEntityType:completion: 调用。但是,在被授予访问权限后,我没有得到任何来源/defaultCalendar 或基于实体的日历。而且我无法创建新日历。

调用 defaultCalendarForNewEvents 时出现此错误

Error Domain=EKCADErrorDomain Code=1013 "The operation couldn’t be completed. (EKCADErrorDomain error 1013.)" 结果为零。

如果我退出 viewController 尝试执行此操作并返回,一切正常。如果在收到关于没有来源的警报后,我继续尝试(没有退出 viewController),它会反复失败。

我想强调,授权调用有效(用户被要求访问日历并提供它,然后调用以确认授权通过)。我发现的所有其他类似的问题都作为解决方案 - 确保您 requestAccessToEntityType

granted返回 true 并且 [self doScheduleActivity: 被调用。下面的代码是在该例程的最开始调用的一个函数,也是失败的地方。

尽管已获得授权,但一切都返回 nil 并且签入[EKEventStore authorizationStatusForEntity:EKEntityType返回 EKAuthorizationStatusAuthorized

在我在这里遇到故障后,如果我退出这个视图控制器并重新进入,它就可以工作。这只发生在系统第一次要求用户访问日历并且他们回复 OK 时。

感谢您的任何见解。我一直在逐步调试调试器,并进行 printf 类型调试以避免任何时间问题等,并且没有看到与我在 Apple 网站上查找的事件内容相反的内容。

我的目标设备是 6.1.3 iPhone 5

0 投票
1 回答
4626 浏览

ios - 对日历守护程序的谓词调用失败:错误域 = EKCADErrorDomain 代码 = 1013

对日历守护程序的谓词调用失败:错误域 = EKCADErrorDomain 代码 = 1013“操作无法完成。(EKCADErrorDomain 错误 1013。)”

我正在尝试从默认应用中获取提醒。

---- 获取日期提醒-----

我收到此错误:- 对日历守护程序的谓词调用失败:错误域 = EKCADErrorDomain 代码 = 1013“操作无法完成。(EKCADErrorDomain 错误 1013。)”

请帮忙。

0 投票
1 回答
968 浏览

iphone - EKEvent 没有根据 EKRecurrenceRule 添加

我正在尝试在日历上创建一个重复事件。我创建了一个 EKRecurrenceRule 并将其设置为该事件。但是该事件不是根据我的重复规则创建的。

这是我的代码,

使用此代码,事件仅在 6 月的每个第一个星期四创建,为什么会跳过 7 月?
请让我知道为什么没有根据我设置的重复规则创建事件。