简体   繁体   English

从json数据的ios字符串中拆分字符串?

[英]split string in ios string from json data?

I have one string. 我有一串。 Now I wanted to split this string. 现在,我想分割此字符串。 For static separation I know the code but I don't code for dynamic value. 对于静态分离,我知道代码,但不为动态值编写代码。

my string is 我的绳子是

NSString *str = @"https://graph.facebook.com/v2.5/181054825200000/feed?fields=created_time,message,picture,full_picture,comments.limit%280%29.summary%28true%29,likes.limit%280%29.summary%28true%29&limit=5&format=json&access_token=CAALjFrE5mNYBAOg1EDiUrsE2kr1kIRrLIv7g4OweSMvHso2exB5Dttshn7dgOlW24ZCXSnDZAWiV6xMUKXedTXUhiHpdmZBPCGzD1orFlrLRP2gaBZCbZBZBnjUHewF9hZBmJKxtiwVzpw9gnnQXk5Hfx0ZBM2ksAUzkSWR5feaNMbf3UUmUpJlxeh0gKdDrzWBvIJRPy0xGqL0ZAMFsRhyCZCTX42l1sZAceZB0VCeDZB95mrAZDZD&until=1456345291&__paging_token=enc_AdCKD3tSYMoZB3MCKaJkYnbVmBgUyY2tBceGDD2G1hqxRDiQKZCsSbmvWZASLvlCMf0BVzq2uZAScSWp7ZAavZB2d72BIHJISefk09noRuv9gA5b5hFwZDZD";

but i don't how to show any value dynamically .(for eg until (in string)) 但是我不怎么动态显示任何值。(例如直到(在字符串中))

please help me for this issue. 请帮我解决这个问题。

Thank You. 谢谢。

For separate string by a separator you can use this. 对于用分隔符分隔的字符串,可以使用它。

NSString *url = @"<url>";
NSArray *array = [url componentsSeparatedByString:@"<seperator string>"];
NSLog(@"%@", array);

But for URL parsing ,As per Duncan's answer, yes it is good to parse a URL using NSURLComponents . 但是根据Duncan的回答,对于URL解析,是的,最好使用NSURLComponents解析URL。 By using this class you can get any desired part of an URL. 通过使用此类,您可以获取URL的任何所需部分。

If you are parsing a URL you should really use NSURLComponents. 如果要解析URL,则应使用NSURLComponents。 It makes breaking a URL into the different parts much easier, and the code is tested and verified by Apple. 它使将URL分解为不同部分变得更加容易,并且代码已由Apple测试和验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM