With Nullability in this case, you should create a reference and check if it is nil before passing it to a method that expects nonnull. It's an extra little bit of code but it does exactly what this warning expects and is for. It's really the right thing to do based on what the API expects.
Sent from my iPhone > On Feb 26, 2016, at 8:38 AM, Jens Alfke <j...@mooseyard.com> wrote: > > >> On Feb 25, 2016, at 3:31 PM, Quincey Morris >> <quinceymor...@rivergatesoftware.com> wrote: >> >> It’s another example of the “any cast is a bug waiting to happen” problem >> that’s inherent in C-like languages. > > To be fair, C++ does have const_cast, which only casts away ‘const’. > >> For this situation it would be nice if there was a cast like this: >> [hostArray addObject: (_Nonnull) url.host]; > > That’s exactly what the NOTNULL macro in my first message does. Its value has > the same type as its argument, just with _Nonnull: > #define NOTNULL(X) ((__typeof(X) _Nonnull)(X)) > > ―Jens > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Xcode-users mailing list (Xcode-users@lists.apple.com) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/xcode-users/dangerwillrobinsondanger%40gmail.com > > This email sent to dangerwillrobinsondan...@gmail.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (Xcode-users@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com This email sent to arch...@mail-archive.com