• 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
error in using NSNumber's numberWithInt: method not flagged
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

error in using NSNumber's numberWithInt: method not flagged


  • Subject: error in using NSNumber's numberWithInt: method not flagged
  • From: Boyd Collier <email@hidden>
  • Date: Sun, 09 Jun 2013 13:26:09 -0700

Quite by chance, I stumbled on to what seems to be an error that ought to be caught by the compiler but wasn't.  Here's an example:

	NSNumber *testNumber = [NSNumber numberWithInt:5];
	int testInt = (int)testNumber;

However, the value of testInt when running the above is wildly incorrect (as one would expect).

The similar code

	NSNumber *testDouble = [NSNumber numberWithDouble:5.77];
       	double myDouble = (double)testDouble;

is flagged with the error message "Pointer cannot be cast to type 'double' ", as it should be.

I'm running OSX 10.7.5 with Xcode 4.6 and using LLVM (I presume).

Should I file a bug report or is this a well-known anomaly that I've just come across?

Boyd



_______________________________________________

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

  • Follow-Ups:
    • Re: error in using NSNumber's numberWithInt: method not flagged
      • From: Jens Alfke <email@hidden>
    • Re: error in using NSNumber's numberWithInt: method not flagged
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: NSURLConnection and 404
  • Next by Date: Re: error in using NSNumber's numberWithInt: method not flagged
  • Previous by thread: UICollectionView with NSFetchedResultsController; compatible?
  • Next by thread: Re: error in using NSNumber's numberWithInt: method not flagged
  • Index(es):
    • Date
    • Thread