objective c - Obj-c/cocoa: When I click a button, an infinite loop starts, data appears corrupted? -


question posted here: http://www.daniweb.com/software-development/objective-c/threads/453854/nstableview-is-not-updating-correctly has full code.

gui:

i'm using nsmutablearray store strings populate nstableview on form. using button action delete specified row. rows specified value stored in int, updates when click on table.

when click button on form activates method:

-(ibaction)removefromlist:(id)sender {     nslog(@"count: %d, at: %d\n",count,at);     if(at<count)     {           [list removeobjectatindex:at];     }     [_table reloaddata];     at=count+1;     count--;     [_label setstringvalue:[self converttonsstring:at]]; } 

table points table, removefromlist called remove, int @ specifies row removed, list nsmutablearray, count total number of rows. _label points label @ bottom of screen, tells me @ pointing to. following output:

2013-05-04 02:32:17.874 todolist[571:903] count: 7, at: 2 2013-05-04 02:32:34.763 todolist[571:903] *** -[nscfarray objectatindex:]: index (6) beyond bounds (6) 

last line repeats on , on. don't know whats going on here or should at. can tell thats part of project doesn't work. or should looking @ appreciated.

you're not decrementing count variable after remove object list, numberofrowsintableview: still return old value, tableview:objectvaluefortablecolumn:row: called row no longer exists in array.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -