How to put a date from strftime in a nsstring in obj-c?
i want to be get a date (the current hour) from strftime and get it into a nsstring 开发者_JAVA技巧in obj-c for the iphone-os
I would recommend using NSDate
's descriptionWithCalendarFormat:timeZone:locale:
. More documentation about the call can be found here. The API allows you to specify which component from a date you want output to an NSString
, which is the return result of the API.
Update: If you really want to use strftime
then take the const char*
-typed result from that call and convert it to an NSString*
by using stringWithUTF8String
. More info on that here.
http://dblog.com.au/iphone-development/iphone-sdk-tip-function-for-getting-formatted-date-string-as-nsstring/
精彩评论