ios - NSDateComponentsFormatter Units Separator -


i want convert time in minutes user friendly string. following code resolves issue, except 1 thing - want result 1 hr 30 min, got 1 hr, 30 min. how specify units separator nsdatecomponentsformatter? of course, can remove commas manually, isn't looks best way me.

    nsdatecomponentsformatter *formatter = [[nsdatecomponentsformatter alloc] init];     formatter.allowedunits = nscalendarunitday | nscalendarunithour | nscalendarunitminute;     formatter.unitsstyle = nsdatecomponentsformatterunitsstyleshort;      nslog(@"%@", [formatter stringfromtimeinterval:90*60]); 

if application targeting os x 10.12 (or later, presume) or ios 10.10 (or later), apple added new units style called "nsdatecomponentsformatterunitsstylebrief"

formatter.unitsstyle = nsdatecomponentsformatterunitsstylebrief 

and print out "1 hr 30 min"

https://developer.apple.com/reference/foundation/nsdatecomponentsformatterunitsstyle/nsdatecomponentsformatterunitsstylebrief?language=objc


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -