Converting integer/numeric values to Strings

Member
Posts: 29
Joined: 2006.07
Post: #1
My problem is : I need to take the numeric score value stored in an 'int' variable and convert it to an NSString or similar object that I can use to draw the score directly on to the screen. I can't seem to find any way to convert it, and using [NSString stringWithFormat:]; isn't working for me.

I'm sure this is pretty simple...any ideas?
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #2
The proper way to do it with an NSString is
[NSString stringWithFormat:@"%d", intValue];
Of course, you will need to either retain it or use copy, otherwise it will be deleted next time the autorelease pool is emptied.
Quote this message in a reply
Member
Posts: 29
Joined: 2006.07
Post: #3
Thanks! I knew I was missing something simple. The game also crashes on my girlfriend's computer for some reason, even though the completely compiled game runs fine as a stand-alone executable on my computer. We also have the exact same computer : iBook G4 1.33 / 512 with Mac OS 10.4. I'm thinking it's either A) she needs a system update, B) I have a memory leak, or C) there's a problem loading the music, sound, and graphics on her computer. The last version of the game I sent her ran fine, but this one gives her a "Ended unexpectedly" error when she tries to run it. Any ideas of what's most likely wrong? I'm going to mess with it and tighten up my code and see if this fixes the issue.
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #4
check console.app for error information, if there isnt anything put NSLog's in and around bits of code you think could be causing the crash.. like loading game resources.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #5
Did you build with zerolink?
Quote this message in a reply
Member
Posts: 29
Joined: 2006.07
Post: #6
Nope..I'm using the "Release" build configuration.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  generate MD5 strings with Objective-C? fernandovalente 3 4,415 Jan 27, 2010 09:29 AM
Last Post: Hog
  Use an integer value as part of a variable name PHANTOMIAS 5 4,004 Dec 8, 2009 09:24 AM
Last Post: PHANTOMIAS
  Die-hard vertex-sorting function not accepting input values! mikey 6 3,928 Oct 31, 2009 03:36 AM
Last Post: mikey
  C strings mikey 24 8,702 May 18, 2009 04:52 AM
Last Post: Oddity007
  Where are strings? Tekkan 2 2,791 Jun 17, 2007 02:44 AM
Last Post: Fenris