ipad - Core Data example, Invalid update: invalid number of rows in section 0 -


i novice @ ios , xcode, , working through core data tutorial , stumped. continually error in error logs of following:

exception type:  exc_crash (sigabrt) exception codes: 0x0000000000000000, 0x0000000000000000 crashed thread:  0  dispatch queue: com.apple.main-thread  application specific information: iphone simulator 235, iphone os 4.2 (ipad/8c134) *** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'invalid update: invalid number of rows in section 0.  number of rows contained in existing section after update (0) must equal number of rows contained in section before update (0), plus or minus number of rows inserted or deleted section (1 inserted, 0 deleted).' *** call stack @ first throw: (         0   corefoundation                      0x010a6be9 __exceptionpreprocess + 185         1   libobjc.a.dylib                     0x00e9b5c2 objc_exception_throw + 47         2   corefoundation                      0x0105f628 +[nsexception raise:format:arguments:] + 136         3   foundation                          0x000b447b -[nsassertionhandler handlefailureinmethod:object:file:linenumber:description:] + 116         4   uikit                               0x00336a0f -[uitableview(_uitableviewprivate) _endcellanimationswithcontext:] + 8424         5   uikit                               0x00325f81 -[uitableview insertrowsatindexpaths:withrowanimation:] + 56         6   simpleres                           0x00002496 -[rootviewcontroller addreservation] + 465         7   uikit                               0x002b9a6e -[uiapplication sendaction:to:from:forevent:] + 119         8   uikit                               0x004c7167 -[uibarbuttonitem(uiinternal) _sendaction:withevent:] + 156         9   uikit                               0x002b9a6e -[uiapplication sendaction:to:from:forevent:] + 119         10  uikit                               0x003481b5 -[uicontrol sendaction:to:forevent:] + 67         11  uikit                               0x0034a647 -[uicontrol(internal) _sendactionsforevents:withevent:] + 527         12  uikit                               0x003491f4 -[uicontrol touchesended:withevent:] + 458         13  uikit                               0x002de0d1 -[uiwindow _sendtouchesforevent:] + 567         14  uikit                               0x002bf37a -[uiapplication sendevent:] + 447         15  uikit                               0x002c4732 _uiapplicationhandleevent + 7576         16  graphicsservices                    0x018bda36 purpleeventcallback + 1550         17  corefoundation                      0x01088064 __cfrunloop_is_calling_out_to_a_source1_perform_function__ + 52         18  corefoundation                      0x00fe86f7 __cfrunloopdosource1 + 215         19  corefoundation                      0x00fe5983 __cfrunlooprun + 979         20  corefoundation                      0x00fe5240 cfrunlooprunspecific + 208         21  corefoundation                      0x00fe5161 cfrunloopruninmode + 97         22  graphicsservices                    0x018bc268 gseventrunmodal + 217         23  graphicsservices                    0x018bc32d gseventrun + 115         24  uikit                               0x002c842e uiapplicationmain + 1160         25  simpleres                           0x00001ab0 main + 102         26  simpleres                           0x00001a41 start + 53 ) 

here addreservation code:

-(void)addreservation{      // create , configure new instance of event entity.     reservations *reservation = (reservations *)[nsentitydescription insertnewobjectforentityforname:@"reservations" inmanagedobjectcontext:managedobjectcontext];      [reservation setend_time: [[nsdate alloc]init]];     [reservation setreservation_date:[[nsdate alloc]init]];     [reservation setstart_time:[nsdate date]];     [reservation setparty_size: [nsnumber numberwithint:4]];     [reservation setphone_number: [nsnumber numberwithint: 1234567890]];     [reservation setname: @"keith"];     [reservation setnotes: @"he's hot!"];     [reservation setperson_responsible: @"lisa"];     [reservation settables_excluded: @"3,5,8"];      nserror *error = nil;     if (![managedobjectcontext save:&error]) {         }      [resarray insertobject:reservation atindex:0];     nsindexpath *indexpath = [nsindexpath indexpathforrow:0 insection:0];     [self.tableview insertrowsatindexpaths:[nsarray arraywithobject:indexpath]                           withrowanimation:uitableviewrowanimationfade];     [self.tableview scrolltorowatindexpath:[nsindexpath indexpathforrow:0 insection:0] atscrollposition:uitableviewscrollpositiontop animated:yes]; } 

i believe resarray not getting data method input in programatically, not sure, , not sure how fix it.

any appreciated.

i take @ implementation of

- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section 

the error specified occurs when value returned numberofrowsinsection not equal previous value plus number of rows added using insertrowsatindexpaths. if implementation of numberofrowsinsection using [myarray count], make sure array instance used same 1 adding reservation entry. if have not implemented method, problem. here example of how method should look:

- (nsinteger)tableview:(uitableview *)tableview   numberofrowsinsection:(nsinteger)section {     return [resarray count]; } 

as backup, can add log statements list size of array before , after addition, , inside of numberofrowsinsection function.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -