• 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: Strange int behavour
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange int behavour


  • Subject: Re: Strange int behavour
  • From: Hank Heijink <email@hidden>
  • Date: Tue, 23 Jan 2007 17:11:13 -0500

Look at the format string in NSLog: %i is int pointer. You want %d.

;-)

Hank

On Jan 23, 2007, at 5:04 PM, d2kagw wrote:

hi all,

I'm having some really strange issues with converting a NSString to an int.
Examine the following peice of code, and


	// declared elsewhere
	NSString * theKey = @"A23456789";

// problem code
NSString * ttSession = [theKey substringWithRange:NSMakeRange( 1, ( [theKey length] - 1 ) )];
NSLog ( @"%@ == %i", ttSession, [ttSession intValue] );



now I was hoping that it would result in this

	"23456789 == 23456789"

but instead I get

	"23456789 == 2147483647"

and just to make it totally confusing, if I change "theKey" to something different I still get "2147483647" as the value???

im totally stumped, and im sure its going to be something totally silly like "you forgot a comma" or something :D

Cheers

Az



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


Hank Heijink www.hankheijink.com email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: Strange int behavour
      • From: Hank Heijink <email@hidden>
References: 
 >Strange int behavour (From: d2kagw <email@hidden>)

  • Prev by Date: Strange int behavour
  • Next by Date: Re: Strange int behavour
  • Previous by thread: Strange int behavour
  • Next by thread: Re: Strange int behavour
  • Index(es):
    • Date
    • Thread