开发者

Insert a string to a string in Objective C

I need to insert a stri开发者_Python百科ng 'GMT' into

"2010-07-13T11:22:33-07:00"

before the last '-' (it could also be a '+') the result should be

"2010-07-13T11:22:33GMT-07:00"


Have a look at the NSString and NSMutableString documentation. I believe what you're looking for is something along the lines of the following (I haven't tested this code, but judging by the documentation it should work):

NSMutableString* date = @"2010-07-13T11:22:33-07:00";
NSRange r = [date rangeOfString:@"-" options:NSSearchBackwards];
[date replaceCharactersInRange: r withString: @"GMT-"];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜