当我尝试在块对象中显示 UIAlertView 时,我得到了 EXEC_BAD_ACCESS。如果我从“viewDidAppear”方法调用“onEventAdded”方法,则警报按预期工作。
提前致谢。
- (void) addEvent:(NSDictionary *) event_data
{
NSLog(@"event_data: %@ ",event_data);
// create event
EKEventStore *store = [[EKEventStore alloc] init];
[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
// event code ...
NSError *err;
[store saveEvent:event span:EKSpanThisEvent error:&err];
if(err == NULL)
{
[self onEventAdded];
}
}];
}
-(void) onEventAdded{
uiAlert = [[UIAlertView alloc]initWithTitle: nil
message: @"Event added to calendar."
delegate: nil
cancelButtonTitle:nil
otherButtonTitles:@"OK",nil];
[uiAlert show];
}