Using Swift-2.2,
I would like to pass a 'struct' or a 'class object' to userInfo of a UILocalNotification. (see code-illustration below).
Can you tell me how this struct needs to be changed in order to be conform to the requirements of the UserInfo ?
I read something about
a) UserInfo can't be a struct (but I also tried with a class - it did not work either)
b) "plist type" conformity --> but how would I do so ?
c) "NSCoder" and "NSObject" conformity --> but how would I do so ?
The error message I get running the code below is:
"unable to serialize userInfo"
Thank you for any help on this.
struct MeetingData {
let title: String
let uuid: String
let startDate: NSDate
let endDate: NSDate
}
let notification = UILocalNotification()
notification.category = "some_category"
notification.alertLaunchImage = "Logo"
notification.fireDate = NSDate(timeIntervalSinceNow: 10)
notification.alertBody = "Data-Collection Request!"
// notification.alertAction = "I want to participate"
notification.soundName = UILocalNotificationDefaultSoundName
let myData = MeetingData(title: "myTitle",
uuid: "myUUID",
startDate: NSDate(),
endDate: NSDate(timeIntervalSinceNow: 10))
// that's where everything crashes !!!!!!!!!!!!!!
notification.userInfo = ["myKey": myData] as [String: AnyObject]