• 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: Formatting integer value
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Formatting integer value


  • Subject: Re: Formatting integer value
  • From: Charlton Wilbur <email@hidden>
  • Date: Mon, 14 Feb 2005 08:18:27 -0500


On Feb 14, 2005, at 8:02 AM, René Korthaus wrote:

i have a problem: I read an integer value from an xml file (plist format) which is the duration of a song.
The formatted integer value is like "325407", where 325 are seconds and 407 are milliseconds. Now i want to make a 3:25 string out of it to display the duration of that song in a tableview. I cannot figure out how to drop the 407ms off that integer value.

You could treat it like a string and chop off the rightmost three characters. See the -stringValue method of NSNumber, and the +stringWithFormat:, -substringFromIndex:, -substringToIndex:, and -substringWithRange: messages in NSString.


You could treat it like an integer, and do an integer division by 1000.

It's probably also worth noting that 325 seconds is *not* the same as 3 minutes and 25 seconds. In that case you'll have to do some (fairly basic) math to convert.

Charlton



--
Charlton Wilbur
email@hidden
email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Formatting integer value
      • From: "M. Uli Kusterer" <email@hidden>
    • Re: Formatting integer value
      • From: Andy Armstrong <email@hidden>
References: 
 >Formatting integer value (From: RenĂ© Korthaus <email@hidden>)

  • Prev by Date: Nimoy S Johnson is out of the office.
  • Next by Date: Re: Formatting integer value
  • Previous by thread: Formatting integer value
  • Next by thread: Re: Formatting integer value
  • Index(es):
    • Date
    • Thread