reading EKCalendarItem notes in swift

I've been searching everywhere for this and so far found a post similar to mine on SO (http://stackoverflow.com/questions/37691680/ekevents-notes-are-nil-in-app-but-exist-in-calendar) with the exact same problem which no one has answered since the beginning of the year.


Description: Creating a Calendar event and saving it then retrieving it for display works beautifully. Only the notes are not being returned and is set as "nil". However, viewing the actual event in the calendar does display the notes correctly so reading the attribute is the issue.


Sample code for retrieval to be displayed on a UITableView:

  for event in events{
  let theStartDate = event.startDate
  let theEndDate = event.endDate
  let theTitle = event.title
  let theNotes = event.notes
  let formatter = NSDateFormatter()
  formatter.timeStyle = .ShortStyle
  //date values being passed in from a custom calendar
  let sTime = formatter.stringFromDate(theStartDate)
  let eTime = formatter.stringFromDate(theEndDate)
  let thisEvent = ["startDate": sTime, "endDate": eTime, "title": theTitle, "notes": String(theNotes)]
  //populates an array which is then presented in a UITableView
  eventCalendar.append(thisEvent)
  }


The Apple API reference (https://developer.apple.com/reference/eventkit/ekcalendaritem/1507507-notes) says it's a get set type of attribute but something is off here.


If someone can shed some light on this problem please let me know how to solve it because I hate to fake notes and retrieve it as something else.


Thanks!

Replies

This sounds like a fairly straightforward bug in EKCalendarItem; there doesn’t seem to be any way that you could be triggering this (that is, the APIs to fetch events don’t give you the option to return partially populated events). I recommend that you file a bug about this, and then post your bug number, just for the record.

One thing that’s worth trying would be to enumerate the events using

enumerateEvents(matching:using:)
to see if those events are fully populated.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"