Newbie Question regarding Classes


I have a quick question.

When sending the message:
NSDate *now = [NSDate date];

Does the message cause an instance of NSDate to be created, which runs the method ‘date’, stores the results in memory and returns the memory location to the pointer ‘now’? Or, is a whole instance of the entire NSDate Class stored at the memory location stored in the ‘now’ pointer?


In the expression [NSDate date], date is a class method which creates an instance of NSDate.

After the statement NSDate *now = [NSDate date] executes, now contains the address of an object, an instance of NSDate.




Hi stuffler94,

Going by your question, I am assuming this is your first book with regards iOS programming?

If so, I would highly recommend you getting hold of an Objective-C book (such as that by BNR), as you will most likely come unstuck as you work your way through this book.