I want to be able to display the system timezone as separate plain text in my app when it launches:
- (void)viewDidLoad {
[super viewDidLoad];
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
NSString* date = [dateFormatter stringFromDate:[NSDate date]];
lblDate.text = date;
NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
[dateFormatter setTimeZone:gmt];
NSString* zone = [gmt:[NSTimeZone defaultTimeZone]];
txtTZ.text = zone;`
My app can display the date correctly but crashes upon the timezone. Any suggestions?
Try replacing this:
With this: