无论用户是否允许访问日历,我都有返回 iOS6 的方法。
-(NSString *)CheckCalendarAllowed{
__block NSString *AllowCalendar;
EKEventStore *eventStore = [[EKEventStore alloc] init];
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if(granted){
NSLog(@"Event store granted");
AllowCalendar = @"1";
NSLog(@"AllowCalendar in block = %@",AllowCalendar);
}else{
NSLog(@"Event store not granted");
AllowCalendar = @"0";
NSLog(@"AllowCalendar in block = %@",AllowCalendar);
}
}];
NSLog(@"AllowCalendar before return = %@",AllowCalendar);
return AllowCalendar;
}
在控制台中我得到了这个。
2012-12-16 20:48:18.418 22052012_xxxx[4346:907] 返回前允许日历 = (null)
2012-12-16 20:48:18.460 22052012_xxxx[4346:110b] 授予事件存储
2012-12-16 20:48:18.462 22052012_xxxx[4346:110b] 块中的 AllowCalendar = 1
完成所有 requestAccessToEntityType 块后如何调用 Return 参数?