Mic*_*fen 2 ios eventkit ekevent
我正在构建一个日历应用程序,并且在尝试保存某些事件时偶尔会遇到一个奇怪的错误.我还没有能够可靠地产生一个复制问题的事件,但我很幸运(如果你可以称之为)再次遇到这个bug.
问题是,当我保存某些事件时,他们拒绝保存其重复规则.大多数事件保存完全没问题,从来没有问题.
我在下面包含了我的调试输出.第一部分EVENT描述了事件对象在打开进行编辑时的情况.第二部分,EVENT TO SAVED,描述事件对象就在它被保存之前.最后一节"EVENT SAVING ERROR"描述了该EKEventStore saveEvent:span:commit:error:方法设置的误差.
任何帮助将非常感激.
2013-12-23 11:47:23.641 planner[4360:60b] EVENT: EKEvent <0x1554d5d0>
{
EKEvent <0x1554d5d0>
{ title = Test repeat m;
location = ;
calendar = EKCalendar <0x1564cfc0> {title = Calendar; type = Local; allowsModify = YES; color = #CC73E1;};
alarms = (null);
URL = (null);
lastModified = 2013-12-23 17:31:29 +0000;
timeZone = America/Chicago (CST) offset -21600
};
location = ;
startDate = 2013-12-23 07:00:00 +0000;
endDate = 2013-12-23 08:00:00 +0000;
allDay = 0;
floating = 0;
recurrence = (null);
attendees = (null)
};
2013-12-23 11:47:32.480 planner[4360:60b] EVENT TO BE SAVED: EKEvent <0x1554d5d0>
{
EKEvent <0x1554d5d0>
{ title = Test repeat m;
location = ;
calendar = EKCalendar <0x1564cfc0> {title = Calendar; type = Local; allowsModify = YES; color = #CC73E1;};
alarms = (null);
URL = (null);
lastModified = 2013-12-23 17:31:29 +0000;
timeZone = America/Chicago (CST) offset -21600
};
location = ;
startDate = 2013-12-23 07:00:00 +0000;
endDate = 2013-12-23 08:00:00 +0000;
allDay = 0;
floating = 0;
recurrence = EKRecurrenceRule <0x155a3d10> RRULE FREQ=DAILY;INTERVAL=1;
attendees = (null)
};
2013-12-23 11:47:32.492 planner[4360:60b] EVENT SAVING ERROR: Error Domain=EKErrorDomain Code=28 "The repeat field cannot be changed." UserInfo=0x155826a0 {NSLocalizedDescription=The repeat field cannot be changed.}
Run Code Online (Sandbox Code Playgroud)
AHA!我终于搞清楚了!如果使用跨度保存重复事件EKSpanThisEvent,则它将变为"已分离".这可以通过调用来检查[event isDetached].我们不允许在分离事件上保存重复规则.
我用于我的应用程序的解决方案是在用户编辑分离事件时隐藏用于设置重复规则的控件.这似乎与Apple在默认日历应用中使用的解决方案相同.