Advertisement
Guest User

Untitled

a guest
Apr 25th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  2. {
  3. // Return the number of sections.
  4. return 2;
  5. }
  6.  
  7. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  8. {
  9. // Return the number of rows in the section.
  10. int count;
  11. switch (section) {
  12. case 0:
  13. count = [_objectArray count];
  14. break;
  15. case 1:
  16. NSLog(@"section called"); // This line is logged
  17. count = 1;
  18. default:
  19. count = 0;
  20. break;
  21. }
  22. return count;
  23. }
  24.  
  25. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  26. {
  27. static NSString *CellIdentifier = @"myCellIdentifier";
  28. static NSString *basicCellIdentifier = @"myBasicCellIdentifier";
  29.  
  30. switch ([indexPath section]) {
  31. case 0: {
  32. TableViewStoryCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier
  33. forIndexPath:indexPath];
  34.  
  35. // Configure the cell...
  36. int theIndex = [indexPath row];
  37. MyObject *theObj = [_objectArray objectAtIndex:theIndex];
  38. cell.object = theObj;
  39. return cell;
  40. break;
  41. }
  42. case 1: {
  43. NSLog(@"cell called"); //this line isn't logged
  44. for (int i = 0; i < 50; i++) {
  45. NSLog(@"hahaha");
  46. }
  47. MyBasicViewStoryCell *cell = [tableView dequeueReusableCellWithIdentifier:basicCellIdentifier forIndexPath:indexPath];
  48. return cell;
  49. break;
  50. }
  51. default: {
  52. for (int i = 0; i < 50; i++) {
  53. NSLog(@"hahaha1");
  54. }
  55. return nil;
  56. break;
  57. }
  58. }
  59. }
  60.  
  61. case 1:
  62. NSLog(@"section called"); // This line is logged
  63. count = 1;
  64. break; // always put break!
  65.  
  66. switch (section) {
  67. case 0:
  68. count = [_objectArray count];
  69. break;
  70. case 1:
  71. NSLog(@"section called"); // This line is logged
  72. count = 1;
  73. break; // Here
  74. default:
  75. count = 0;
  76. break;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement