• 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: convert int to NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >convert int to NSString (From: Adam <email@hidden>)
 >Re: convert int to NSString (From: Sherm Pendley <email@hidden>)
 >Re: convert int to NSString (From: John Randolph <email@hidden>)

  • Prev by Date: DO and Rendezvous
  • Next by Date: Running a modal session
  • Previous by thread: Re: convert int to NSString
  • Next by thread: DO and Rendezvous
  • Index(es):
    • Date
    • Thread