我是一名 c++ 和 c 程序员,而且我是 Objective-C 世界的新手,所以我在理解它的工作原理时遇到了一些问题,这里有一个简短的代码,这让我很困惑,
#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; }
现在是指向对象类型 NSdate 我的问题是为什么我们不能这样做:
double seconds = [NSDate timeIntervalSince1970];
通常第一部分是对象的类型,第二部分是方法如果这是一个不好的问题,我很抱歉,但我想从一开始就很好地理解 Objective-C。谢谢