Advertisement
Guest User

Untitled

a guest
Jul 1st, 2012
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.60 KB | None | 0 0
  1. Core Data example, Invalid update: invalid number of rows in section 0
  2. Exception Type: EXC_CRASH (SIGABRT)
  3. Exception Codes: 0x0000000000000000, 0x0000000000000000
  4. Crashed Thread: 0 Dispatch queue: com.apple.main-thread
  5.  
  6. Application Specific Information:
  7. iPhone Simulator 235, iPhone OS 4.2 (iPad/8C134)
  8. *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (0) must be equal to the number of rows contained in that section before the update (0), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted).'
  9. *** Call stack at first throw:
  10. (
  11. 0 CoreFoundation 0x010a6be9 __exceptionPreprocess + 185
  12. 1 libobjc.A.dylib 0x00e9b5c2 objc_exception_throw + 47
  13. 2 CoreFoundation 0x0105f628 +[NSException raise:format:arguments:] + 136
  14. 3 Foundation 0x000b447b -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
  15. 4 UIKit 0x00336a0f -[UITableView(_UITableViewPrivate) _endCellAnimationsWithContext:] + 8424
  16. 5 UIKit 0x00325f81 -[UITableView insertRowsAtIndexPaths:withRowAnimation:] + 56
  17. 6 SimpleRes 0x00002496 -[RootViewController addReservation] + 465
  18. 7 UIKit 0x002b9a6e -[UIApplication sendAction:to:from:forEvent:] + 119
  19. 8 UIKit 0x004c7167 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 156
  20. 9 UIKit 0x002b9a6e -[UIApplication sendAction:to:from:forEvent:] + 119
  21. 10 UIKit 0x003481b5 -[UIControl sendAction:to:forEvent:] + 67
  22. 11 UIKit 0x0034a647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
  23. 12 UIKit 0x003491f4 -[UIControl touchesEnded:withEvent:] + 458
  24. 13 UIKit 0x002de0d1 -[UIWindow _sendTouchesForEvent:] + 567
  25. 14 UIKit 0x002bf37a -[UIApplication sendEvent:] + 447
  26. 15 UIKit 0x002c4732 _UIApplicationHandleEvent + 7576
  27. 16 GraphicsServices 0x018bda36 PurpleEventCallback + 1550
  28. 17 CoreFoundation 0x01088064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
  29. 18 CoreFoundation 0x00fe86f7 __CFRunLoopDoSource1 + 215
  30. 19 CoreFoundation 0x00fe5983 __CFRunLoopRun + 979
  31. 20 CoreFoundation 0x00fe5240 CFRunLoopRunSpecific + 208
  32. 21 CoreFoundation 0x00fe5161 CFRunLoopRunInMode + 97
  33. 22 GraphicsServices 0x018bc268 GSEventRunModal + 217
  34. 23 GraphicsServices 0x018bc32d GSEventRun + 115
  35. 24 UIKit 0x002c842e UIApplicationMain + 1160
  36. 25 SimpleRes 0x00001ab0 main + 102
  37. 26 SimpleRes 0x00001a41 start + 53
  38. )
  39.  
  40. -(void)addReservation{
  41.  
  42. // Create and configure a new instance of the Event entity.
  43. Reservations *reservation = (Reservations *)[NSEntityDescription insertNewObjectForEntityForName:@"Reservations" inManagedObjectContext:managedObjectContext];
  44.  
  45. [reservation setEnd_Time: [[NSDate alloc]init]];
  46. [reservation setReservation_Date:[[NSDate alloc]init]];
  47. [reservation setStart_Time:[NSDate date]];
  48. [reservation setParty_Size: [NSNumber numberWithInt:4]];
  49. [reservation setPhone_Number: [NSNumber numberWithInt: 1234567890]];
  50. [reservation setName: @"Keith"];
  51. [reservation setNotes: @"He's really hot!"];
  52. [reservation setPerson_Responsible: @"Lisa"];
  53. [reservation setTables_Excluded: @"3,5,8"];
  54.  
  55. NSError *error = nil;
  56. if (![managedObjectContext save:&error]) {
  57. }
  58.  
  59. [resArray insertObject:reservation atIndex:0];
  60. NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
  61. [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
  62. withRowAnimation:UITableViewRowAnimationFade];
  63. [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
  64. }
  65.  
  66. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  67.  
  68. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  69. return [resArray count];
  70. }
  71.  
  72. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  73. {
  74. // Return the number of rows in the section.
  75. return [recentImages count];
  76. }
  77.  
  78. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  79.  
  80. // Delete from underlying data source first!
  81. recentImages = [recentImages removeObjectAtIndex:indexPath.row];
  82.  
  83. // Then perform the action on the tableView
  84. if (editingStyle == UITableViewCellEditingStyleDelete)
  85. {
  86. [tableView beginUpdates];
  87. [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
  88. withRowAnimation:UITableViewRowAnimationFade];
  89. [tableView endUpdates];
  90. }
  91.  
  92. // Finally, reload data in view
  93. [self.tableView reloadData];
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement