objective c - Create an NSString with leading zeroes for minutes and seconds -


i need update playback time in label. getting time nstimeinterval currentprogress = self.movieplayercontroller.currentplaybacktime; returns double value. format in need display "mm:ss" (00:00). have tried following code

nstimeinterval currentprogress = self.movieplayercontroller.currentplaybacktime;  float min = floor(currentprogress/60); float sec = round(currentprogress - min * 60); 

when progress time 10 minutes , 10 seconds displays fine, "10:10". problem here if progress time 1 minute , 7 seconds, displays "1:7" in label. intended display "01:07". how can that?

nsstring *time = [nsstring stringwithformat:@"%02d:%02d", (int)min, (int)sec]; 

try this. should work!


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -