Removing events from iPhone calendar with EKEventStore

后端 未结 2 767
野性不改
野性不改 2020-12-29 00:48

I\'m trying to remove events that i have created from the iPhone calendar.

I tried this, but it always returns NO:

  [eventStore removeEvent:event sp         


        
2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-29 01:26

    After creating the event I save the eventIdentifier in an array:

    [eventStore saveEvent:event span:EKSpanThisEvent error:&err]; 
       NSString* str = [[NSString alloc] initWithFormat:@"%@", event.eventIdentifier];
    [arrayofCalIDs addObject:str];
    

    To delete the events:

    EKEventStore* store = [[[EKEventStore alloc] init] autorelease];
       EKEvent* event2 = [store eventWithIdentifier:[arrayofCalIDs objectAtIndex:i]];
    if (event2 != nil) {  
      NSError* error = nil;
      [store removeEvent:event2 span:EKSpanThisEvent error:&error];
    } 
    [myPath release];
    

提交回复
热议问题