objective c - NSTableView edits not changing NSMutableArray -
i have class stores strings along bool flag set yes if 1 of strings has been updated.
i have nstableview displays strings in class. view controlled via separate controller class , view fed nsmutablearray.
the gui stuff seems work fine in terms of displaying data , allowing me edit cells in table view. problem having edits don't change objects stored in nsmutablearray. have debug code print out strings when close app, , none of changes made in gui show in objects @ point. setting break point values changed shows me objects indeed changed, changes seem lost. how can changes make in view persist in object stored in nsmutablearray backing nstableview?
here how coding:
// class .h file @interface snip : nsobject <nsmutablecopying> @property (assign) int64_t id_num; @property (assign) bool changed; @property nsmutablestring *name; @property nsmutablestring *text; @property (copy) nsstring *language; // class .m file import "snip.h" @implementation snip @synthesize id_num; @synthesize name; @synthesize text; @synthesize changed; @synthesize language;
method controller class
// edit table values -(void)tableview:(nstableview *)tableview setobjectvalue:(id)object fortablecolumn(nstablecolumn *)tablecolumn row:(nsinteger)row { snip *sn = [snippet_list objectatindex:row]; [sn setchanged:yes]; [sn setvalue:object forkey:[tablecolumn identifier]]; nslog(@"change: %@",sn.name); }
that last nslog statement displays change made in gui. also, setchanged:yes lost when print nsmutablearray contents when closing app.
this behaviour due data being initialised again @ point after being changed user.
you can catch problem setting breakpoint (or nslog
statement) in initialisation code.
Comments
Post a Comment