UITableViewCell dequeued from UITablView Properly but It not showing the Values that was passed

55 Views Asked by At

I have a Custom UITableViewCell(two UILabels in it) in a UITableView when I am trying to dequeued it works proper but when I am trying to show values that was passed by me in the UITable its not showing in the Custom cell but just dequeued correctly and have a big height(because of this I knew that it was dequeued correctly).

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
EngineerCell *cell = (EngineerCell*) [tableView dequeueReusableCellWithIdentifier:@""];
Engineer *engr = [self.engineers objectAtIndex:indexPath.row];
cell.engrName.text = engr.engrName;
cell.engineType.text = engr.engineType;
cell.experience.text = [NSString stringWithFormat:@"%d",engr.experience];
NSLog(@"a%@a",cell.engrName.text);
return cell;
}

It seems no response but dequeued correctly.

2

There are 2 best solutions below

1
Aaron Brager On BEST ANSWER

[inp rangeOfString:@","] returns the first instance of the comma, so when there is a comma as a suffix, you're deleting all of the numbers after the first comma.

You could use [inp rangeOfString:@"," options:NSBackwardsSearch] or split the array with componentsSeparatedByString:, but for a more robust approach, consider replacing all of this with a solution that uses NSScanner.

0
Brian On

[inp hasSuffix:@","] is checking to see if the string has a trailing comma. See the [NSString componentsSeparatedByString:] method - it will save you a lot of trouble.