首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >xcode将NSString拆分到其他NSStrings

xcode将NSString拆分到其他NSStrings
EN

Stack Overflow用户
提问于 2011-11-24 19:09:03
回答 2查看 18.1K关注 0票数 6
代码语言:javascript
复制
{"Title":"Chatroom","Year":"2010","Rated":"R","Released":"11 Aug 2010","Genre":"Drama, Thriller","Director":"Hideo Nakata","Writer":"Enda Walsh, Enda Walsh","Actors":"Aaron Johnson, Imogen Poots, Matthew Beard, Hannah Murray","Plot":"A group of teenagers encourage each other's bad behavior.","Poster":"http://ia.media-imdb.com/images/M/MV5BMjE0MjM5MDM2MF5BMl5BanBnXkFtZTcwMzg1MzY0Mw@@._V1._SX320.jpg","Runtime":"1 hr 37 mins","Rating":"5.3","Votes":"1000","ID":"tt1319704","Response":"True"}

我使用nsstring获取此数据,我的问题是如何将这些数据拆分到另一个nsstring中,但我希望使用尽可能多的逗号作为nsstring

EN

回答 2

Stack Overflow用户

发布于 2011-11-24 19:43:17

请使用以下内容

代码语言:javascript
复制
NSString *str; //Pass your string to str
NSArray *array = [str componentsSeparatedByString:@","];

for(int i = 0; i < [array count]; i++) {
  // Here just take strings one by one
}
票数 14
EN

Stack Overflow用户

发布于 2011-11-24 20:43:01

代码语言:javascript
复制
    NSString *string= //pass the string whatever you want.
    NSArray *splitArray = [string componentsSeparatedByString:@","]; //it separates the string and store it in the different different indexes.

Ex:
    NSString *str= @"one,two,three";
    NSArray *array = [str componentsSeparatedByString:@","]; //it separates the string and store it in the different different indexes(one is at index 0 ,two is at index 1 and three is at index 2).
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8256080

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档