开发者

How to add characters to a NSString?

i have strings who look like this 20110525 .

How to add characters to a NSString?

how can i make to put '-' caracters in NSString variable ? to let dates look like this 2011-05-25 ? My second question is how can i sort the dat开发者_如何学Goes to make the table look like this 20110525 then 20110526 ?Help please . Thank you


Why not just use the NSDate class to get the date, and use an NSDateFormatter to format the date the way you want.


you can try using sscanf(input,"%4d%2d%2s",&year,&month,&day) to parse input string and sprintf(output,"%d-%d-%d",year,month,day) to format your date.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜