I am developing a calendar app and I've run into a problem with the way EKCalendarEvents handle titles in Swift.
In Swift 1.2 the title property has the type String!.
This leads one to think that the title can not be null, however, this is not the case. It is possible to create an event with null title using Outlook calendar (simply create an event, do not change anything and save). This will produce an event with no title.
Reading this by writing
let eventTitle = someEKEvent.titlewill lead to a crash, one must test for an empty title by using
if let eventTitle = someEKEvent.title {
// ...
}I have not yet used this API in Swift 2.0, but I can see that the title property has been declared _Nonnull and the Swift type is now a plain String.
My question is: Is this a bug in the Swift API? Does the new Obejctive-C code replace missing titles with empty strings now? Should I make a new radar?
I am new to the forums, please feel free to correct me if there are any issues with my question.
Thank you
It is possible to create an event with null title using Outlook calendar (simply create an event, do not change anything and save).
Quite. If that's the case then either the EKCalendarEvent implementation needs to be fixed (so it doesn't return nil in this case) or its header needs to change (so it doesn't claim to not return nil).
Please file a bug about this, then post your bug number here, just for the record.
I am new to the forums, please feel free to correct me if there are any issues with my question.
You're doing well so far (-:
Share and Enjoy
—
Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"