• 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: string formatting (correction)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string formatting (correction)


  • Subject: Re: string formatting (correction)
  • From: Dave Hersey <email@hidden>
  • Date: Wed, 3 Oct 2007 16:38:17 -0400

Stupid floats. I always mess that up.

Try this:

someString = [NSString stringWithFormat: @"%dhdm.2fs", hours, minutes, seconds];

- d


On Oct 3, 2007, at 4:28 PM, Dave Hersey wrote:

Just use standard printf style attributes in your format string:

someString = [NSString stringWithFormat: @"%dhdm.2fs", hours, minutes, seconds];

- d

On Oct 3, 2007, at 4:14 PM, H M wrote:

hi.
I have written a method that puts out an NSstring like "12h12m12.34s" using a string format. that works ok, but there is something I don't like: when the number of minutes or seconds is less than 10, it'll put out only 1 digit instead of 2. like this: "1h1m1.23s". is there a way to force leading zeros in there, like this: "1h01m01.23s"? i don't need a leading zero for the hours.
Do I have to make 3 NSstrings (for hours, minutes and seconds) with leading zeros and then stick them together? I think I can get that sorted, but that would be a lot of work. is there an easier way?
_______________________________________________

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:
40herseyweb.com


This email sent to email@hidden

_______________________________________________

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


  • Follow-Ups:
    • Re: string formatting (correction)
      • From: H M <email@hidden>
References: 
 >string formatting (From: H M <email@hidden>)
 >Re: string formatting (From: Dave Hersey <email@hidden>)

  • Prev by Date: Re: Should I be trying to use bindings for this?
  • Next by Date: Re: Distinguish between Directory and File
  • Previous by thread: Re: string formatting
  • Next by thread: Re: string formatting (correction)
  • Index(es):
    • Date
    • Thread