简体   繁体   English

与Google日历同步

[英]Synchronization with google calendar

I want to synchronise all events with Google Calendar. 我想将所有事件与Google日历同步。 I used the following code to do this: 我使用以下代码执行此操作:

EKEventStore *eventStore = [[[EKEventStore alloc] init] autorelease]; 
    calendarsArray = [[NSArray alloc] init];
    calendarsArray = [[eventStore calendars] retain];
    EKCalendar *calendar = [calendarsArray objectAtIndex:1];
    [events setCalendar:calendar];
    NSError *err;
    [eventStore saveEvent:events span:EKSpanThisEvent error:&err];
But I am not getting google calendar at object at index(1). 但是我没有在index(1)的对象处获取google日历。 So Can anybody help me to solve this problem. 所以有人可以帮我解决这个问题吗?

Please note that calendars is deprecated in iOS 6 use this instead: 请注意,iOS 6中不建议使用日历,请改用以下方法:

(NSArray *)calendarsForEntityType:(EKEntityType)entityType

Entity type then needs to be one of these: 然后,实体类型必须是以下类型之一:

typedef enum {
   EKEntityTypeEvent,
   EKEntityTypeReminder
} EKEntityType;

This should give you the expected result, more info: https://developer.apple.com/library/ios/documentation/EventKit/Reference/EKEventStoreClassRef/Reference/Reference.html#//apple_ref/occ/instm/EKEventStore/calendarsForEntityType : 这应该给您预期的结果,更多信息: https : //developer.apple.com/library/ios/documentation/EventKit/Reference/EKEventStoreClassRef/Reference/Reference.html#//apple_ref/occ/instm/EKEventStore/calendarsForEntityType

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM