【问题标题】:EKCalendar and Error Domain=NSMachErrorDomain Code=268435459EKCalendar 和错误域=NSMachErrorDomain 代码=268435459
【发布时间】:2012-07-10 12:31:03
【问题描述】:

我正在探索 EKEventKit。 我连接我的 iPhone 并拨打电话以安装日历

EKEventStore *eventDB = [[EKEventStore alloc] init];
NSArray * calendars = [eventDB calendars ];

但是,当我记录日历时,我会收到此错误消息

"CADObjectGetIntProperty 失败并出现错误错误 Domain=NSMachErrorDomain Code=268435459 "无法进行操作 完全的。 (马赫错误 268435459 - (ipc/send) 无效目的地 端口)”

有谁知道这是什么以及为什么我会得到它。 谢谢

雷扎

【问题讨论】:

标签: ios calendar ekeventkit


【解决方案1】:

我发现了问题。

我之前在我的代码中加载并保留了一个 EKEventStore。删除其中一个解决了问题

雷扎

【讨论】:

  • 我也有同样的问题,而且我认为它的根本原因是一样的,我试过[商店发布];无济于事,您实际上是如何解决的?
  • 我在我的项目中使用自动引用计数。在启动时,我创建了一个分配给变量的 EKEventStore,因此它被保留,然后我将该 EventStore 用于我的所有日​​历调用。
  • 是的,这就是我最终采用的方法。谢谢。
  • 谢谢,这只是 iOS5 的错误,现在已修复。谢谢
【解决方案2】:

我的控制台上有相同的警告日志

早期代码:

"CalendarEventHandler.m"
eventStore = [[EKEventStore alloc] init];


"CalendarEventHandler.h"

@property (nonatomic,strong) EKEventStore *eventStore;

代码修改

self.eventStore = [[EKEventStore alloc] init];//This helped me to remove warning

【讨论】:

    【解决方案3】:

    @discussion to EKEventStore class EKEventsStore.h 文件说:

    "It is generally best to hold onto a long-lived instance of an event store, most likely as a singleton instance in your application."

    这里也是这样写的:Reading and Writing Calendar EventsConnecting to the Event Store部分:

    "An EKEventStore object requires a relatively large amount of time to initialize and release. Consequently, you should not initialize and release a separate event store for each event-related task. Instead, initialize a single event store when your app loads, and use it repeatedly to ensure that your connection is long-lived."

    所以正确的做法是:

    @interface MyEventStore : EKEventStore
    
    + (MyEventStore *)sharedStore;
    
    @end
    
    + (MyEventStore *)sharedStore
    {
        static dispatch_once_t onceToken;
        static MyEventStore *shared = nil;
        dispatch_once(&onceToken, ^{
            shared = [[MyEventStore alloc] init];
        });
        return shared;
    }
    
    @end
    

    并使用它调用[MyEventStore sharedStore]

    这种方法还修复了警告。

    【讨论】:

      【解决方案4】:

      将实例'eventDB'设为类成员变量或属性可以解决问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-02-10
        • 1970-01-01
        • 2017-06-16
        • 2018-08-18
        • 2020-05-06
        • 2017-11-30
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多