NSLocale is mostly empty - where are the attributes?

I just want to know if the iPhone user has set the time display to 12 hours.

The class NSLocale

seemed to describe (in undefined non-specific terms with no examples or seemingly helpful methods) what I was after.

So, I created several NSLocale

objects:

NSLocale *systemLocaleApparently = [NSLocale systemLocale];
NSLocale *currentLocaleWithLotsOfGoodies = [NSLocale autoupdatingCurrentLocale];

      

When I check these objects with the debugger, or the NSLog()

best I can get is something like these lines:

<CFLocale 0x1278e0 [0x382084f8]>{type = system, identifier = ''} 

      

The current locale has an ID string in it, but nothing else.

From the documentation I can search for values ​​from locale and one of them is an object NSCalendar

. So I bring it back and look at him and he tells me it's "gregorian".

All of them seem to be useful to someone ... but I'd really like a nice big attribute dictionary displaying all the actual system properties, mostly so that mine NSDateFormatters

doesn't bloat when the user selects the 12 hour format, though I made the formatters use language en_US_POSIX

and fixed format setDate

.

(i'm sure NSCalendarDate

never used these problems ...)

Hope I missed something overtly (and probably embarrassingly), obviously, but maybe someone would kind of share it with me. You are welcome:)

+2


source to share


1 answer


Here's one way to find out if a custom time format is set to 12-hour or 24-hour:



NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setTimeStyle:NSDateFormatterMediumStyle];
// Look for H (24-hour format) vs. h (12-hour format) in the date format.
NSString* dateFormat = [formatter dateFormat];
BOOL using24HourClock = [dateFormat rangeOfString:@"h"].location == NSNotFound;

      

+3


source







All Articles