Re: convert int to NSString
Re: convert int to NSString
- Subject: Re: convert int to NSString
- From: Ondra Cada <email@hidden>
- Date: Thu, 22 Apr 2004 11:35:49 +0200
Adam,
On 22.4.2004, at 7:31, John Randolph wrote:
>
>> (int x = 27)
>
>> how do I convert it into an NSString so I can display it somewhere
>
>> in the GUI?
>
>
>
> sx = [NSString stringWithFormat:@"%d", x];
>
> sx = [[NSNumber numberWithInt: x] stringValue];
>
>
Personally, I'm partial to the latter, since it doesn't require a
>
constant string object or the overhead of parsing a format string.
>
Not that it would matter much unless you're doing this a few thousand
>
times a second.
Also please note that if you happen to use an NSTextView (or just
anything which contains a cell), you don't need to convert it at all:
[viewOrCell setIntValue:x] would do quite nicely.
Actually, I'd say those cases where you would really need to convert
values to strings to display them in GUI are pretty rare.
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.