2

My EKEvent is not saving in my iphone 5 ios 6.1 but its saved on my ipod 6.0. and When I update my event and save it , the event is deleted. Please help me fix it. Its it a ios bug? or just in the code?

this is my code:

- (IBAction)submitButtonPressed:(id)sender {
    if (!self.eventStore) {
        self.eventStore = [[[EKEventStore alloc]init]autorelease];
    }

    if (!self.event) {
        self.event  = [EKEvent eventWithEventStore:self.eventStore];
    }

    if ([self.eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)])
    {
        // the selector is available, so we must be on iOS 6 or newer
        [self.eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
            dispatch_async(dispatch_get_main_queue(), ^{
                if (error)
                {
                    NSLog(@"error: %@",error);
                    // display error message here
                }
                else if (!granted)
                {
                    NSLog(@"error: Access Denied");
                    // display access denied error message here
                }
                else
                {
                    // access granted
                    if (!self.isEditing) {
                        [self.event setCalendar:[self.eventStore defaultCalendarForNewEvents]];
                    }
                    [self sendEvent];

                }
            });
        }];
    }
    else
    {
        [self.event setCalendar:[self.eventStore defaultCalendarForNewEvents]];
        [self sendEvent];
    }
}

-(void)sendEvent {
    self.event.title = self.eventModel.eventName;
    self.event.location = self.eventModel.eventLocation;
    self.event.notes = self.eventModel.eventDescription;
    self.eventModel.date = self.datePicked;
    NSString *fromTime = [NSString string];
    NSString *toTime = [NSString string];
    if (self.eventModel.fromTime) {
        fromTime = [NSString stringWithFormat:@"%@:%@",[ self.eventModel.fromTime objectForKey:@"hour"],[self.eventModel.fromTime objectForKey:@"minute"]];
    }

    if (self.eventModel.toTime) {
        toTime = [NSString stringWithFormat:@"%@:%@",[ self.eventModel.toTime objectForKey:@"hour"],[self.eventModel.toTime objectForKey:@"minute"]];
    }

    //set start date and time
    NSDateFormatter *tempFormatter = [[[NSDateFormatter alloc]init] autorelease];
    [tempFormatter setDateFormat:@"yyyy-MM-dd hh:mm"];
    NSString *dateandtime =[NSString stringWithFormat:@"%@%@%@",self.eventModel.fromDate,@" ", fromTime];

    //set end date and time
    NSDateFormatter *tempFormatterTo = [[[NSDateFormatter alloc]init] autorelease];
    [tempFormatterTo setDateFormat:@"yyyy-MM-dd hh:mm"];
    NSString *dateandtimeTo =[NSString stringWithFormat:@"%@%@%@",self.eventModel.toDate,@" ", toTime];

    self.event.startDate = [tempFormatter dateFromString:dateandtime];
    self.event.endDate = [tempFormatterTo dateFromString:dateandtimeTo];
    self.event.allDay = self.eventModel.allDay;

    [self.eventStore saveEvent:self.event span:EKSpanFutureEvents error:&err];

}
Edgar
  • 179
  • 11
  • Can you post your code, that will give us more to go on. – rckoenes May 24 '13 at 09:45
  • are you sure you have perrmission to acces calander on ur Iphone 5, try resetting Go to Settings > Privacy > Calander and reset it. may solve the problem – Bonnie May 24 '13 at 10:15
  • yes i have a permission to access the calendar. actually i can get the events on the calendar the only thing i can't do is save a new event. – Edgar May 24 '13 at 10:22
  • @user1672796 I face same problem.... if you have solution for this, please give answer... and @ JgdGuy have the same problem in http://stackoverflow.com/questions/16854064/ekevents-ekreminders-set-but-are-not-displaying-on-calendar – DharaParekh Jun 05 '13 at 11:55

0 Answers0