Re: Formatting integer value
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