2013-03-04 41 views
0

这是我的场景:iOS日历限制导致应用崩溃

我正在从我的应用向iOS日历添加事件。在添加事件(显示日历的添加事件视图)之前,如果用户转到设置 - >常规 - >限制 - >日历并限制我的应用程序的权限,那么应用程序会崩溃。

有没有人遇到过这样的问题?任何线索?因为xcode在崩溃时没有给出任何相关日志。我正在iOS 6.0 iPod Touch中运行应用程序。

希望有人能帮上忙。

回答

0

首先获取访问日历事件的权限,然后添加事件。 获取权限的代码

EKEventStore eventStore = [[EKEventStore alloc] init];

if ([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)]) 
{ 
    [eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) 
    { 
     if (granted){ 

      MLLog(@"Wipe : getEventStorePermission : permission granted"); 
     } 
     else{ 
      MLLog(@"Wipe : getEventStorePermission : permission not granted"); 
     } 
    }]; 
} 
else{ 

    MLLog(@"Wipe : getEventStorePermission : permission not required"); 
} 

RELEASE_OBJECT(eventStore)