Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String tokenizer in Objective-C for iPhone application development

I am writing a string tokenizer in Objective-C for an iPhone application.

I have the result as:

1|101|Y|103|Y|105|Y|107|Y|109|Y|111|Y|113|Y|115|Y|

I want to tokenize this string and display each of the values in tabular format. How am I to do it?

I want the result in a tabular format. Like:

102 Y
103 Y
..  ...
like image 429
shreedevi Avatar asked Nov 06 '09 06:11

shreedevi


1 Answers

If by “tokenizing” you mean simply “splitting on the pipe-sign”, you can use the componentsSeparatedByString: method of NSString:

 NSString *original = @"1|101|Y|103|Y|105…";
 NSArray *fields = [original componentsSeparatedByString:@"|"];

“Displaying in a tabular format” doesn’t say much. If you want a classic table, see the UITableView class.

like image 181
zoul Avatar answered Oct 06 '22 00:10

zoul