Objective C code question
Posted on 2012-03-20
I'm working my way through a book on Obj C. Please look at the code below and my explanation and tell me why my results are not the same with using the Class and Instance methods.
If I use the class method of systemTimeZone it's telling me (I think) that I am on Daylight savings time.
However, If I use an instance method for isDaylightSavingTime I am getting a 0 returned.
int main (int argc, const char * argv)
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSTimeZone *zone = [[NSTimeZone alloc] init]; // Create an instance
NSTimeZone *c = [NSTimeZone systemTimeZone]; // Class method so don't need to create an instance
NSLog(@"Time zone is %@\n", c);
BOOL z =[zone isDaylightSavingTime];
NSLog(@"Is it set to Daylight Savings time: %d\n", z);
2012-03-20 11:05:02.525 TimeZone[1259:903] Time zone is US/Eastern (EDT) offset -14400 (Daylight)
2012-03-20 11:05:02.526 TimeZone[1259:903] Is it set to Daylight Savings time: 0