I have string whose value are like FirstName;LastName;Phone e.g.
Tom;Hanks;12346789
I am populating a UIVewTable Label text is suposed to be FirstName,LastName e.g.
Tom,Hanks
Then I put the phone in details bit.
I am splitting the String based on semiColumn ;
then concatenating the first two elements of array and comma and third element in description.
NSArray *title = [[dataArray objectAtIndex:indexPath.row] componentsSeparatedByString:@";"];
//This bit below does not look right.
cell.textLabel.text = [[[title objectAtIndex:0] stringByAppendingString:@","] stringByAppendingString:[title objectAtIndex:1]];
cell.detailTextLabel.text = [title objectAtIndex:2];
开发者_运维知识库
Slightly better solution:
cell.textLabel.text = [NSString stringWithFormat:@"%@,%@", [title objectAtIndex:0], [title objectAtIndex:1]];
精彩评论