k4l*_*lls 1 frameworks objective-c nsdate
我是Objective-C的新手,我正在尝试插入NSdate,但我不知道要包含哪个库以便调用它.我尝试了以下但没有成功.谢谢你的帮助

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
#include <CoreFoundation/CoreFoundation.h>
// Get current datetime
NSDate *currentDateTime = [NSDate date];
// Instantiate a NSDateFormatter
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
// Set the dateFormatter format
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
// Get the date time in NSString
NSString *dateInString = [dateFormatter stringFromDate:currentDateTime];
// Release the dateFormatter
[dateFormatter release];
Run Code Online (Sandbox Code Playgroud)
小智 5
您已经包含了所有必需的标题,并且您添加了所有必需的框架(NS*类所需的只有Foundation).问题是你的陈述没有范围.例如,在main()函数中包装它们.
| 归档时间: |
|
| 查看次数: |
145 次 |
| 最近记录: |