The following code does not compile in Swift 2.0
var eventsIds : [CalendarEventLink?] = [CalendarEventLink?](count: 5, repeatedValue: nil)
var data = try NSJSONSerialization.dataWithJSONObject(eventsIds, options: [])
I'm getting error:
'[CalendarEventLink?]' is not convertible to '[AnyObject]'
How can I serialise array to json in swift?
[CalendarEventLink?](count: 5, repeatedValue: nil)creates an array of 5 xnil:[nil, nil, nil, nil, nil], but you can't encodenilinto JSON.if...letto decide if it is not an optional.