开发者社区 问答 正文

动态添加字符串到NSString中

NSString的内容来自一个URL,我希望添加一些字符串到里面。而且这个NSString会实时改变。

比如:

获取的数据是:" hi mac this is ios"然后字符串就会改变为:" hi ios this mac" or hi this is mac ios"

在mac后面就加上hello:变成这样:

" hi mac hello this is ios"
" hi ios this mac hello"
"hi this is mac hello ios"

该如何实现?

展开
收起
爵霸 2016-03-26 10:10:34 1899 分享 版权
1 条回答
写回答
取消 提交回答
  • string = [string stringByReplacingOccurrencesOfString:@"Mac" withString:@"Mac Hello"];

    2019-07-17 19:15:30
    赞同 展开评论
问答分类:
问答地址: