upvote
When Swift 1 came out, I was migrating an ObjC app that used CoreData to it and found a bug where nullable cols in the CoreData schema got non-nullable properties in the autogenerated Swift. Found out when I had a non-nullable property actually get set to null at runtime, and the compiler wouldn't let me add a check that it's null.
reply
Obj-C does have a "nonnull" annotation now (apparently added to assist Swift interop). One of the final jigsaw pieces turning it into a really pleasant language.
reply
nonnull doesn't really do anything in pure objc. It warns if you assign the nil literal to a nonnull pointer and that's it. The annotation is almost entirely for the sake of Swift interop (where it determines if the pointer is bridged as an Optional or not).
reply
It is a really pleasant language, but I think the <nonnull> annotation is for initialization only - compiler checking against initializing an object ptr with a null value - and does not prevent crashing when addressing an already released object
reply
I don't think objc has the equivalent of a null pointer exception. You can freely send messages to a deallocated object. Since ARC, it is rare, at least in my experience, running into any memory related issues with objc.
reply
You can send messages to `nil`, but the inverse isn't universally true. APIs like

  [text stringByAppendingString:other]; 
will throw an `NSInvalidArgumentException` if `other` is nil.
reply
You can send messages to null, sendings messages to a deallocated pointer is going to be a bad time.
reply
It’s nice not to crash, but unexpected null can still cause bugs in ObjC when the developer isn’t paying attention.

Having done both ObjC with nonnull annotations, and Swift, I agree that it’d be hard to forgo the having first-class support for Optionals

reply
deleted
reply
Objective-C did not have null pointer exceptions, though some libraries added them.
reply
If you use Objective-C objects, operations on null pointers are just a no-op, so there is not such thing as chasing exceptions.
reply
So you silently ignore something being null when you don't expect it to be? That sounds even worse.
reply