-3

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.

sarosh siddiq
  • 33
  • 1
  • 7
  • 2
    Have you tried splitting the string into an array with something like `NSArray *frequencies = [inp componentsSeparatedByString: @","];` ? – Chris Stokes Mar 30 '15 at 15:39

2 Answers2

3

[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.

Brian
  • 15,599
  • 4
  • 46
  • 63
1

[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.

Aaron Brager
  • 65,323
  • 19
  • 161
  • 287