In Swift 2.x, the following code would fail to compile:
let anArray = NSMutableArray()
let something = callSomethingThatReturnsAnOptionalObject()
anArray.addObject(something) << error "value of optional type '***?' not unwrapped."
Whereas in Swift 3 the equivalent happily compiles:
let anArray = NSMutableArray()
let something = callSomethingThatReturnsAnOptionalObject()
anArray.add(something)
and in the case where 'something' end up as a nil optional the code will happily continue until some Obj-C code tries to use that 'nil' optional. In my case it was NSCoder trying to encode the array and failing when it hit the offending item.
This seems really dangerous, why was it allowed to happen. Seems like a regression to me?
(I haven't checked, but I suspect other NSMutableXXX containers can suffer the same issue)