开发者

how to split to get in one unit

开发者 https://www.devze.com 2023-04-03 13:08 出处:网络
I have the text in a string as shown below NSString *total_duration= 2 days 5 hours 6 min Bas开发者_如何学Cically I would like each to get in one unit likein minute. How can i get this

I have the text in a string as shown below

NSString *total_duration= 2 days 5 hours 6 min

Bas开发者_如何学Cically I would like each to get in one unit like in minute. How can i get this

NSInteger *total_duration_inMin=2*24*60+5*60+6


Well if the format of your string remains same all the time then you can use this

NSArray *array = [total_duration componentsSeparatedByString:@" "];

NSInteger a = [[array objectAtIndex:0] intValue] * 24 * 60 + [[array objectAtIndex:2] intValue] * 60 + [[array objectAtIndex:4] intValue];
0

精彩评论

暂无评论...
验证码 换一张
取 消