简体   繁体   中英

splitting NSString element based on the special character in iphone

I'm getting a string from xml as |Name|Id|Address| I want only the contents which are inside "|" that is Name and Address should be added to one array,Id should come in different array.How to split this string in to the array required

Try this:

NSArray *strComp = [string componentsSeparatedByString:@"|"];

This should give you an array containing [@"Name", @"Id", @"Address"]

You can then sort in to separate arrays as necessary.

Hope this helps to get you on your way!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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