• 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: a string from an integer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a string from an integer


  • Subject: Re: a string from an integer
  • From: Olivier Lanctôt <email@hidden>
  • Date: Wed, 23 Jul 2003 23:39:19 -0400

You have to draw a line between C types (int, double, floats, long, char, etc) and objects (in cocoa, things that are prefixed with NSObject or object that are subclasses of NSObject)

Objects can receive messages (things between [ ]) and c types cannot.

If you want to work with ints as objects, you'd have to use NSNumber.

Example:

NSString *intAsString;
NSNumber *number = [NSNumber numberWithInt:100];

intAsString = [number stringValue];

If you don't want to deal with NSNumber, which is perfectly normal, then do something like

int number = 100;
intAsString = [NSString stringWithFormat:@"%d", number];

I'd recommend you to go buy a cocoa book.

--Jean-Olivier

On Wednesday, July 23, 2003, at 11:29 PM, Lazee Software wrote:

ok... well
NSString *someString;
int someinteger = 100;

someString =[someinteger stringValue];

does not yield a string which is the number help in someinteger.
Why can't I get a string from a number?

I could just put it in the textfield, then pull it back but that seems like a huge waste of cycles.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >a string from an integer (From: Lazee Software <email@hidden>)

  • Prev by Date: a string from an integer
  • Next by Date: Re: Bug reports and documentation updates
  • Previous by thread: a string from an integer
  • Next by thread: Re: a string from an integer
  • Index(es):
    • Date
    • Thread