NSTimeZone init question


I’m really enjoying this book and appreciate all of the hands on opportunities. Since I was motoring through the book and got to chapter 23, and began feeling a little lost, I decided to go back and reread from chapter 12. It’s really been helpful.

My question is pretty basic, and hopefully I didn’t miss the answer elsewhere in the forum, but here it is:

When I run the following code I get the expected output of the date.

NSDate *now = [[NSDate alloc] init];
NSLog(@“The date is %@”, now);

If I understand this correctly - now - is an instance of NSDate on the heap and even though I did not use the class method date during the initialization the date was stored in the memory location pointed to by - now.

So, my question is about the following code:

NSTimeZone *tz = [[NSTimeZone alloc] init];

But here the output is (null). Why? Since I know I can use an instance method as in - bool dot = [tz isDaylightSavingsTime] and it works, why can’t I output what tz is?

I read through some of the documentation on NSTimeZone but I’m still unclear.

Thank you again. You guys are great. I hope to get a chance to come to the Ranch once I get through a couple of books.



Definitely a common question, so you’re in good company.

We’ve covered it a couple of times, but yours is the first thread to be titled explicitly with the question involved, so hopefully that’ll make it easier for others to find the answer in the future.


If you don’t feel like those fully answer your question, please don’t hesitate to follow up and ask more questions. This is definitely can be confusing, but it’s vital in the long run to understand how to create objects.


Thanks so much for the links to the answers.

I went and looked at the documentation for NSDate and NSTimeZone so I could see for myself that init does not show up in Creating and Initializing for NSTimeZone. So I had also misunderstood the use of alloc and init for creating an object of the class.