相关疑难解决方法(0)

defaultCalendarForNewEvents失败

当我尝试调用[newEventStore defaultCalendarForNewEvents]时,它会返回一条错误消息:

[707:907] defaultCalendarForNewEvents failed: Error Domain=EKCADErrorDomain Code=1013 "The operation couldn’t be completed. (EKCADErrorDomain error 1013.)"
[707:907] Error!Failed to save appointment. Description:Error Domain=EKErrorDomain Code=1 "No calendar has been set." UserInfo=0x1fc679f0 {NSLocalizedDescription=No calendar has been set.}
Run Code Online (Sandbox Code Playgroud)

该应用程序运行了很长时间.我第一次遇到这个问题.手机运行IOS6 Beta4.model是iphone 4.有没有人知道defaultCalendarForNewEvents方法什么时候会失败?我无法通过谷歌搜索获得任何有用的信息.

calendar ios

32
推荐指数
4
解决办法
2万
查看次数

如何在ios 6上创建和保存EKCalendar

我有一个问题,我创建我的EKCalendar,一切看起来不错,但是当我去列出我的日历时,它没有出现.我也去我的日历应用程序查看我的日历列表,但它不存在.有什么想法吗?

这是我创建日历的按钮代码:

- (IBAction)one:(id)sender {
NSString* calendarName = @"My Cal";
EKCalendar* calendar;

// Get the calendar source
EKSource* localSource;
for (EKSource* source in eventStore.sources) {
    if (source.sourceType == EKSourceTypeLocal)
    {
        localSource = source;
        break;
    }
}

if (!localSource)
    return;

calendar = [EKCalendar calendarWithEventStore:eventStore];
calendar.source = localSource;
calendar.title = calendarName;

NSError* error;
bool success= [eventStore saveCalendar:calendar commit:YES error:&error];
if (error != nil)
{
    NSLog(error.description);
    // TODO: error handling here
}
NSLog(@"cal id = %@", calendar.calendarIdentifier);
}
Run Code Online (Sandbox Code Playgroud)

这是我的按钮代码列出日历,但我的新日历从未包括在内!

- (IBAction)two:(id)sender {

NSArray …
Run Code Online (Sandbox Code Playgroud)

calendar objective-c ios ios6

14
推荐指数
2
解决办法
8007
查看次数

无法在日历中添加事件

我想在“someName”日历中添加事件。如果不存在具有给定名称的日历,那么我将以编程方式创建一个。我的问题是当 localSource(EKSource 类型)结果为空时,不会添加该事件。我添加了 3 个检查以确保我获得 localSource 的值,但即使在某些情况下 localSource 也是 nil。所以在我的手机上添加了事件,但在我朋友的手机上却没有。

我关注了各种帖子,我了解到 EKSource 可以是 6 种类型:https : //developer.apple.com/reference/eventkit/eksourcetype

我不明白的是在什么情况下 localSource 会为零?这在普通语言中是什么意思?我可以从代码中做一些事情来使它非零还是用户必须在设备上做一些事情?

- (void)setCalendar {
    NSArray *calendars = [self.eventStore calendarsForEntityType:nil];
    NSString *calendarTitle = someName;
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"title matches %@", calendarTitle];
    NSArray *filtered = [calendars filteredArrayUsingPredicate:predicate];
    if ([filtered count]) {
        self.calendar = [filtered firstObject];
    }
    else {
        self.calendar = [EKCalendar calendarForEntityType:EKEntityTypeEvent eventStore:self.eventStore];
        self.calendar.title = calendarTitle;
        EKSource *localSource;
        for (EKSource *source in self.eventStore.sources)
        {

            //if iCloud account is setup then add …
Run Code Online (Sandbox Code Playgroud)

events calendar objective-c ios

4
推荐指数
1
解决办法
770
查看次数

标签 统计

calendar ×3

ios ×3

objective-c ×2

events ×1

ios6 ×1