在我的日历iOS中有我的事件的endHourTime:Obj-C

时间:2014-04-19 12:45:44

标签: ios iphone xcode events ekeventstore

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

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

首先,我想制作一个应用程序,告诉我在活动结束前还剩多少时间。 该事件是我的日历与我的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];

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

你有什么想法吗?

0 个答案:

没有答案