Re: Displaying '%' in the UI (Velocityboy)
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