NSString操作

ven*_*kat 0 iphone objective-c nsstring

我想像操纵NSString一样

(0)喜欢(1).(见.(2))

(0)=拉曼

(1)=你

(2)= ThisGift

拉曼喜欢你.(见.ThisGift)

我不知道什么approch可以解决这个问题.

在此先感谢,此致

Venkat.

Dav*_*ong 5

-[NSString stringByReplacingOccurrencesOfString:withString:].

你这样使用它:

NSString * source = @"(0) Likes (1). (see. (2))";
source = [source stringByReplacingOccurrencesOfString:@"(0)" withString:@"Raman"];
NSLog(@"%@", source);  //logs "Raman Likes (1). (see. (2))"
Run Code Online (Sandbox Code Playgroud)