Guest User

Untitled

a guest
Jun 20th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. // Return a cell for the ith row
  2. - (UITableViewCell *)tableView:(UITableView *)tView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  3. {
  4. static NSString *CellIdentifier = @"CustomCell";
  5. int row = [indexPath row]; // Set up the cell
  6. //get the # of elements
  7. DataManagment *myManager = [DataManagment sharedDataManager];
  8. NSArray *streams = myManager.results;
  9. NSDictionary *stream = (NSDictionary *)[streams objectAtIndex:row];
  10. CustomCell *cell = (CustomCell *) [text dequeueReusableCellWithIdentifier:CellIdentifier];
  11. if (cell == nil) {
  12.  
  13. NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
  14.  
  15. for (id currentObject in topLevelObjects){
  16. if ([currentObject isKindOfClass:[UITableViewCell class]]){
  17. cell = (CustomCell *) currentObject;
  18. break;
  19. }
  20. }
  21. }
  22.  
  23. [cell.label1 setText:[stream valueForKey:@"titleNoFormatting"]];
  24. [cell.label2 setText:[NSString stringWithFormat:@"%@ %@", [stream valueForKey:@"streetAddress"], [stream valueForKey:@"postal"]]];
  25. [cell.label3 setText:[stream valueForKey:@"distance"]];
  26. [cell.cell_image setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"icon" ofType:@"png" inDirectory:@"/"]]];
  27. return cell;
  28.  
  29. }
Add Comment
Please, Sign In to add comment