objective c - Accessing a variable using string -


i wondering if 1 of me little problem having, if possible. have few global variables called checklista, checklistb, etc. want, if user selects table cell called a, checklista passed on destination controller.

in other words:
global variables: nsarrays -> "checklista", "checklistb", "checklistc", etc.
cells: "a", "b", "c", etc

... on click of cell b...
destinationcontroller.checklist = nsarray named: "checklistb"

hope clear, if have questions feel free ask.

thank in advance!

i believe table view has delegate method implemented:

tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath 

you notified whenever cell selected(tapped) user.

you can implement delegate method in way:

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {    if( indexpath.row == 0) /// first cell    {        _selectedchecklist = checklista;    }    else if( indexpath.row == 1) /// second cell    {        _selectedchecklist = checklistb;    }    else if( indexpath.row == 2) /// third cell    {        _selectedchecklist = checklistc;    } } 

for prepareforsegue, pass value destination viewcontroller:

- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender {    destinationcontroller.checklist = _selectedchecklist;  } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -