Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not exactly. ObjC code cannot usefully benefit from those annotations (yet? more likely ever). At most, it's good for documenting your ObjC code for fellow readers. The actual use appears in the Swiftland where instead of implicitly unwrapped optionals you get proper explicit optionals or explicit non-optionals.


The benefit to working with the Cocoa APIs will be immense, though.

I assume that, now that this feature exists, Apple will begin annotating their Obj-C APIs.


They already started doing it a few months ago with private annotations. This "nonnull"/"nullable" syntax is a result of their work on annotating Cocoa APIs.


They've been doing it for a while in the Swift overlay module. I'm really happy that this is officially added to obj-c because it provides very valuable API documentation, even if it won't have much practical effect on the code.


It looks like the annotations will allow the compiler to produce warnings when compiling the Objective-C code, so that's something:

"However, nullability annotations—in addition to improving the experience in Swift—provide new warnings in Objective-C"




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: