0

我想要在我的日历应用程序上同步的实际事件。

实际事件是现在正在发生的事件。

首先,我想制作一个应用程序,告诉我距离活动结束还有多少时间。该事件是我的日历同步到我的 iPhone。

在我的 Main.StoryBoard 中,我声明了一个标签:

@property (strong, nonatomic) IBOutlet UILabel *currentEvent;

我声明了一个 EKEventStore:

EKEventStore *store = [[EKEventStore alloc] init];

从现在开始,我知道如何创建一个包含开始日期、结束日期的事件。但我想从我当前的事件中检索信息,以便能够做到:endDate - timeActual;

接下来,在我的标签中,会写:活动结束前 57 分钟。

NSLog(@"%i minutes before the end of the event.", remainTime );

我不知道我是否清楚,如果您不明白我在问什么,请告诉我?
谢谢您的帮助!:)

[更新]

我知道如何拥有我的日历的标识符:

EKEventStore *store = [[EKEventStore alloc] init];
store = [[EKEventStore alloc] init];

 [store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
                                if (!granted)
                                    NSLog(@"Access to store not granted");
                            }];
     NSArray *calendars = [store calendarsForEntityType:EKEntityTypeEvent];

  for (EKCalendar *calendar in calendars)
{
    NSLog(@"Calendar = %@", calendar.description);  
    self.currentEvent.text = [NSString stringWithFormat:@"%@", calendar.calendarIdentifier];
}

EKCalendar *myCalendar = calendars[0];
NSLog(@"My Calendar = %@", myCalendar);

EKEvent *actualEvent = [EKEvent eventWithEventStore:store];

我知道如何在我的日历上设置事件,但我的日历中没有事件!

你有什么想法吗?

4

0 回答 0