Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何从EKEvent存储中获取eventIdentifier?_Iphone_Ios_Objective C_Ekeventstore - Fatal编程技术网

Iphone 如何从EKEvent存储中获取eventIdentifier?

Iphone 如何从EKEvent存储中获取eventIdentifier?,iphone,ios,objective-c,ekeventstore,Iphone,Ios,Objective C,Ekeventstore,现在我正在日历应用程序中处理EKEvent mange。我成功地将事件添加到eventStore。我需要从事件存储中获取事件标识符。 我使用以下代码访问eventIdentifier。但我在我的应用程序中总是为evetnIdentifier获取空值 EKEvent *event = [self eventAtIndexPath:indexPath]; NSString *eventIdentifier]; = [[NSString alloc] initWithFormat:@"%@",

现在我正在日历应用程序中处理EKEvent mange。我成功地将事件添加到eventStore。我需要从事件存储中获取事件标识符。 我使用以下代码访问eventIdentifier。但我在我的应用程序中总是为evetnIdentifier获取空值

EKEvent *event = [self eventAtIndexPath:indexPath];    
NSString *eventIdentifier]; = [[NSString alloc] initWithFormat:@"%@",event.eventIdentifier];
试试这个:

在你的

#import <EventKit/EventKit.h>

@property (nonatomic, retain) EKEventStore *eventStore;
@property (nonatomic, retain) EKCalendar *defaultCalendar;
@property (nonatomic, retain) NSMutableArray *eventsList;

希望对你有帮助。快乐编码。谢谢。

能否显示[self-EventIndexPath:indexPath]的代码@Yashesh,我得到event.title和event的其他属性。我无法仅获取eventIdentifier..检查此:-我已回答此问题,希望它有所帮助。
- (void) fetchevents
{

    eventStore = [[EKEventStore alloc] init];

    eventsList = [[NSMutableArray alloc] init];

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

    [store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
        // handle access here
    }];

    // Get the appropriate calendar
NSCalendar *calendar = [NSCalendar currentCalendar];

    // Create the start date components
    NSDateComponents *oneDayAgoComponents = [[NSDateComponents alloc] init];
    oneDayAgoComponents.day = -1; // From which date you have to fetch Events from calander

    NSDate *oneDayAgo = [calendar dateByAddingComponents:oneDayAgoComponents
                                              toDate:[NSDate date]
                                             options:0];

    NSLog(@"%@", oneDayAgo);

    // Create the end date components
    NSDateComponents *oneYearFromNowComponents = [[NSDateComponents alloc] init];
    oneYearFromNowComponents.year = 0;
    NSDate *oneYearFromNow = [calendar dateByAddingComponents:oneYearFromNowComponents
                                                   toDate:[NSDate date]
                                                  options:0];
    NSLog(@"%@", oneYearFromNow);

    //Create the predicate from the event store's instance method
    NSPredicate *predicate = [store predicateForEventsWithStartDate:oneDayAgo endDate:oneYearFromNow                                                                                      calendars:nil];


    NSArray *events_Array = [eventStore eventsMatchingPredicate: predicate];

    for (EKEvent *eventToCheck in events_Array)
    {
       [eventsList addObject:eventToCheck.calendarItemIdentifier ];
    }
}