• 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: Displaying '%' in the UI (Velocityboy)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Displaying '%' in the UI (Velocityboy)


  • Subject: Re: Displaying '%' in the UI (Velocityboy)
  • From: Preston Sumner <email@hidden>
  • Date: Thu, 19 Apr 2012 12:09:33 -0600

On Apr 19, 2012, at 6:57 AM, Kirk Kerekes wrote:

>
> On Apr 18, 2012, at 2:00 PM, email@hidden wrote:
>
>> Re: Displaying '%' in the UI (Velocityboy)
>
> As a possibly more clear alternative to escaping the %, you could use:
>
> [NSString stringWithFormat:@"%.0f%@",ratio1, @"%"]
>
> Or, even more cocoa-fied ObjC:
>
> [NSString stringWithFormat:@"%@%@",[NSNumber numberWithFloat: ratio1], @"%"]
>
> (trusting NSNumber's -description method for formatting)
>
> or,
>
> [NSString stringWithFormat:@"%ul%@",[[NSNumber numberWithFloat: ratio1] integerValue], @"%"]

I strongly recommend just using NSNumberFormatter with NSNumberFormatterPercentStyle, which formats percentage values according to the user's locale.

Preston
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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

References: 
 >Re: Displaying '%' in the UI (Velocityboy) (From: Kirk Kerekes <email@hidden>)

  • Prev by Date: Re: NSDateFormatter problem
  • Next by Date: Re: Updating NSMenu while it's open
  • Previous by thread: Re: Displaying '%' in the UI (Velocityboy)
  • Next by thread: Guidelines on using NSJSONSerialization
  • Index(es):
    • Date
    • Thread