mnem / NilObjCObjectInSwift

Little experiment to check the behaviour of objects that are unexpectedly `nil` in Swift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected nil obj-c objects in Swift

Little experiment to check the behaviour of objects that are unexpectedly nil in Swift. For some reason I assumed there would be a runtime error, but it turns out that isn't the case - it behaves similarly to Obj-C. That is, calling a function on a nil (but non-optional) object is a NOOP. It makes sense if you consider that Swift is really just performing an objc_msgsend under the hood, but it still took me by surprise.

About

Little experiment to check the behaviour of objects that are unexpectedly `nil` in Swift.


Languages

Language:Swift 59.8%Language:Objective-C 40.2%