• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to fix "misuse of 'nonnull'" warnings in Xcode 7.3?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to fix "misuse of 'nonnull'" warnings in Xcode 7.3?


  • Subject: Re: How to fix "misuse of 'nonnull'" warnings in Xcode 7.3?
  • From: email@hidden
  • Date: Fri, 26 Feb 2016 09:42:53 +0900

That's a spanking good example. 
I have run into that myself. 
Unfortunately it's victim to the Swift Nullability universe. 
It is impedance mismatch. 
And why the warnings are off in Objective-C I suppose. 
The count check is a classic guard that tells us it's ok to access objects in that range. 

Arguable the analyzer should know this. 
Sounds like a tools bug then. :)

Sent from my iPhone

On Feb 26, 2016, at 9:14 AM, Jens Alfke <email@hidden> wrote:


On Feb 25, 2016, at 4:02 PM, email@hidden wrote:

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. 

Often, yes. But there are a number of cases where you already know by other means that the value is non-null, for example
if (a.count >= 3)
[widgets addObject: a.firstObject]
Testing a.firstObject for nil would be pointless.

This is the equivalent of those times when you use “!” to dereference an optional in Swift.

—Jens
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >How to fix "misuse of 'nonnull'" warnings in Xcode 7.3? (From: Jens Alfke <email@hidden>)
 >Re: How to fix "misuse of 'nonnull'" warnings in Xcode 7.3? (From: Quincey Morris <email@hidden>)
 >Re: How to fix "misuse of 'nonnull'" warnings in Xcode 7.3? (From: Jens Alfke <email@hidden>)
 >Re: How to fix "misuse of 'nonnull'" warnings in Xcode 7.3? (From: Quincey Morris <email@hidden>)
 >Re: How to fix "misuse of 'nonnull'" warnings in Xcode 7.3? (From: Jens Alfke <email@hidden>)
 >Re: How to fix "misuse of 'nonnull'" warnings in Xcode 7.3? (From: email@hidden)
 >Re: How to fix "misuse of 'nonnull'" warnings in Xcode 7.3? (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: How to fix "misuse of 'nonnull'" warnings in Xcode 7.3?
  • Next by Date: Re: Xcode-users Digest, Vol 13, Issue 52
  • Previous by thread: Re: How to fix "misuse of 'nonnull'" warnings in Xcode 7.3?
  • Next by thread: Re: How to fix "misuse of 'nonnull'" warnings in Xcode 7.3?
  • Index(es):
    • Date
    • Thread