ios - EKEventStore-该事件不属于该事件存储
<p>我根本无法保存提醒/事件。但是,我已被授予使用提醒的权限(我检查了设置)。我已经打印出错误,并显示<code>That event does not belong to that event store.</code>这是我的代码;<br><pre><code>- (void)viewDidLoad
{
;
// Do any additional setup after loading the view.
self.eventStore =[ init];
self.eventStoreAccessGranted = NO;
[self.eventStore requestAccessToEntityType:EKEntityTypeReminder completion:^(BOOL granted, NSError *error) {
self.eventStoreAccessGranted = granted;
if (!granted) {
NSLog(@"User has not granted permission");
}
}];
}
- (IBAction)setAReminder:(id)sender {
if (!self.eventStoreAccessGranted) {
NSLog(@"Reminder is no");
return;
}
NSLog(@"Reminder is YES");
EKReminder * newReminder = [ init];
newReminder.title = @"Pick up the kids";
newReminder.calendar = ;
NSDate *now = ;
NSDate *alarmDate = ;
EKAlarm * ourAlarm = ;
;
NSError *error = nil;
;
NSLog(@"Event %@",);
}
</code></pre><br>有什么建议可能是问题所在吗?</p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p>我将代码更改为此,并且可以正常工作。<br><pre><code> -(IBAction)setAReminder:(id)sender {
if (self.eventStore == nil)
{
self.eventStore = [init];
[self.eventStore requestAccessToEntityType:EKEntityTypeReminder completion:^(BOOL granted, NSError *error) {
if (!granted)
NSLog(@"Access to store not granted");
}];
}
if (self.eventStore != nil)
;
}
-(void)createReminder
{
EKReminder *reminder = [EKReminder
reminderWithEventStore:self.eventStore];
reminder.title = @"Test";
reminder.calendar = ;
NSDate *date = ;
EKAlarm *alarm = ];
;
NSError *error = nil;
;
if (error)
NSLog(@"error = %@", error);
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - EKEventStore-该事件不属于该事件存储,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/24656252/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/24656252/
</a>
</p>
页:
[1]