我从 Google 服务器获取时间为PT4M30S,PT7M2S
. 如果是第一个,即PT4M30S
,那么我将其显示为4:30
。但是第二个是这样来的7:2
,我不想要。我喜欢它7:02
。
这就是我做了一些如何
NSString *m=@"M";
NSString *s=@"S";
NSRange rang =[videoTimeString rangeOfString:m options:NSCaseInsensitiveSearch];
if(rang.length==[m length])
{
if(rang.length==[s length])
{
NSString *string1=[videoTimeString stringByReplacingOccurrencesOfString:@"PT" withString:@""];
NSString *string2=[string1 stringByReplacingOccurrencesOfString:@"M" withString:@":"];
finalTime=[string2 stringByReplacingOccurrencesOfString:@"S" withString:@""];}
else{
NSString *string1=[videoTimeString stringByReplacingOccurrencesOfString:@"PT" withString:@""];
finalTime=[string1 stringByReplacingOccurrencesOfString:@"M" withString:@":00"];
}
}
else{
NSString *string1=[videoTimeString stringByReplacingOccurrencesOfString:@"PT" withString:@"0:"];
finalTime=[string1 stringByReplacingOccurrencesOfString:@"S" withString:@""];
}
所以任何帮助将不胜感激。
谢谢