I'm a c++ & c programmer , and i'm new to the world of objective-C , so i have some problem understanding how it works , here a short code , that confused me,
#import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { @autoreleasepool { NSDate *now = [NSDate date]; NSLog(@"The date is %@", now); double seconds = [now timeIntervalSince1970]; NSLog(@"It has been %f seconds since the start of 1970.", seconds); } return 0; } now is pointer to an object type NSdate my question is why we can not do this :
double seconds = [NSDate timeIntervalSince1970]; normally the first part is the type of the object and the second part is the method i'm sorry if this is a bad question but i want to understand Objective-C very well from the begining. Thanks
Class::classMethod()andmyClass.instanceMethod(). Before learning the language by looking at code, read this: developer.apple.com/library/mac/documentation/Cocoa/Conceptual/…-timeIntervalSince1970is an instance method not a class method. if it'd been a class method, you would have done what you'd like.+dateis a class method not an instance method. that is why.