• 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: Warning about comparison between pointer and integer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Warning about comparison between pointer and integer


  • Subject: Re: Warning about comparison between pointer and integer
  • From: Dave Carrigan <email@hidden>
  • Date: Wed, 16 Dec 2009 08:31:51 -0800

On Dec 16, 2009, at 8:18 AM, Eric E. Dolecki wrote:

> NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
>
> alarm1_hour = [prefs integerForKey:@"alarm1Hour"];
>
> if( alarm1_hour == NULL ){
>
>  NSLog(@"alarm 1 hour is null" );
>
> }

-integerForKey returns a NSInteger. Comparing NSInteger to NULL (which is a declared as a pointer) is going to give you that warning. It certainly makes not sense to compare an integer to NULL.

> Should I use a temporary variable to check instead of the variable with the
> pointer? Or are these warnings okay to ignore?

Warnings are almost never ok to ignore. The compiler is trying to tell you that you're probably doing something wrong.

--
Dave Carrigan
email@hidden
Seattle, WA, USA

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >Warning about comparison between pointer and integer (From: "Eric E. Dolecki" <email@hidden>)

  • Prev by Date: Re: [iPhone] Sample code for live camera stream?
  • Next by Date: Re: Warning about comparison between pointer and integer
  • Previous by thread: Warning about comparison between pointer and integer
  • Next by thread: Re: Warning about comparison between pointer and integer
  • Index(es):
    • Date
    • Thread