ios - UITableView - Check if Cell checkmark -


in uitableview, user can check or not check cell. how can figure out, witch checked , save in array?

with following code, can check cell:

-(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath{      uitableviewcell *cell = [tableview cellforrowatindexpath:indexpath];      if ([cell accessorytype] == uitableviewcellaccessorynone) {         [cell setaccessorytype:uitableviewcellaccessorycheckmark];     }     else {         [cell setaccessorytype:uitableviewcellaccessorynone];     }      [tableview deselectrowatindexpath:indexpath animated:no]; } 

don't check checkmark accessory view of cells. cells being reused , mess logic.

instead, keep mutable set of objects being presented cells 'selected' aka checked.

when user taps cell can toggle membership of presented object in mutable set , update checkmark appropriately.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -