Let's stipulate that _Nullable and _Nonnull are great to have because they can 
catch bugs and express API intent better than before, so we want them. The 
question is where to put them?


_Nullable and _Nonnull make perfect sense to specify in the @interface. Since 
those annotations existing in the @interface will produce applicable warnings 
and errors in the counterpart @implementation,there's really no _need_ to 
respecify them in the @implementation of those same methods. 

It makes sense for private methods to have nullability annotations for all the 
same reasons public Now let's assume that private methods aren't specified in 
any @interface, even the anonymous one. In that case, those methods would 
naturally have no annotations on their parameters or return values unless 
they're specified within the @implementation. But specifying them on the 
private methods in the @implementation while *not* specifying them for the 
public methods in the @implementation is inconsistent and potentially 
confusing. 


So I see two choices here:

1) Always add nullability annotations, for all methods and properties in both 
the @interface and @implementation. (Private methods may or may not be declared 
within @interfaces — but these days I think it's generally not done?)

2) Only add nullability annotations in the @interface, and always declare 
private methods within an @interface.



Is there a third choice I'm not thinking of?


Thoughts? I'm curious how Apple is adopting these annotations themselves.



--
Seth Willits




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to