ios - 即使 EKEvent.hasNotes 返回 YES,EKEvent.notes 也会返回 (null)
<p><p>我在 Xcode 6.0.1 上,使用 Event Kit 制作一个测试应用程序。以下代码成功填充了每个事件的标题,但即使 hasNotes 属性返回 YES,它的注释也会返回为 (null)。而且,我可以在 iPhone 的默认日历应用中看到同一事件的备注。</p>
<p>我做错了什么?</p>
<pre><code>- (void)viewDidLoad
{
;
[eventStore requestAccessToEntityType:EKEntityTypeEvent
completion:^(BOOL granted, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (error)
{
NSLog(@" !! error");
// display error message here
}
else if (!granted)
{
NSLog(@"Not Granted");
// display access denied error message here
}
else
{
// access granted
NSCalendar *calendar = ;
// Create the start date components
NSDateComponents *oneWeekAgoComponents = [ init];
oneWeekAgoComponents.day = -1;
NSDate *oneWeekAgo = options:0];
// Create the end date components
NSDateComponents *oneMonthFromNowComponents = [ init];
oneMonthFromNowComponents.month = 1;
NSDate *oneMonthFromNow = options:0];
// Create the predicate from the event store's instance method
NSPredicate *predicate = ;
// Fetch all events that match the predicate
_eventArray = ;
;
}
});
}];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = ;
EKEvent *event = ;
cell.textLabel.text = event.title;
if (event.hasNotes) {
cell.detailTextLabel.text = event.notes;
} else {
cell.detailTextLabel.text = @"";
}
return cell;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我还没有完全解决,但有一点线索。</p>
<pre><code>NSArray *events = ;
</code></pre>
<p>这没有得到注释。所以,相反,我通过执行来枚举返回的事件</p>
<pre><code> [eventStore enumerateEventsMatchingPredicate:predicate usingBlock:^(EKEvent *event, BOOL *stop) {
NSLog(@"title: %@",event.title);
NSLog(@"hasNotes: %s",event.hasNotes ? "YES":"NO");
NSLog(@"notes: %@",event.notes);
NSLog(@"-----");
;
;
}];
</code></pre>
<p>这个返回实际的笔记(null)。</p></p>
<p style="font-size: 20px;">关于ios - 即使 EKEvent.hasNotes 返回 YES,EKEvent.notes 也会返回 (null),我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/26052460/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/26052460/
</a>
</p>
页:
[1]