https://stackoverflow.com/questions/1835992
题
我想从 strftime 获取日期(当前小时)并将其放入 iphone-os 的 obj-c 中的 nsstring 中
解决方案 2
http://dblog.com.au/iphone-development/iphone-sdk-tip-function-for-getting-formatted-date-string-as-nsstring/
其他提示
我建议使用 NSDate的 descriptionWithCalendarFormat:timeZone:locale:. 。有关调用的更多文档可以找到 这里. 。该 API 允许您指定要输出到日期的哪个组件 NSString, ,即API的返回结果。
NSDate
descriptionWithCalendarFormat:timeZone:locale:
NSString
更新: 如果你真的想使用 strftime 然后采取 const char*-键入该调用的结果并将其转换为 NSString* 通过使用 stringWithUTF8String. 。更多相关信息 这里.
strftime
const char*
NSString*
stringWithUTF8String