As I wrote in the title, I am trying to write down the value selected on a pickerview (populated by an array) to the detailTextLabel
of the cell I clicked to bring up the pickerview. (The pickerview is shown in an actionSheet).
What I tried to do was to set up two mutable arrays: pickerData
and tableData
. Initially, the pickerData
array contains the values shown in the pickerview, and the tableData
array has only one value.
When the following method is called, I'm trying to record the selection onto the tableData
array, and then use this value to replace the original value on the detailTextLabel
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
[tableData replaceObjectAtIndex:row withObject:[pickerData objectAtIndex:row]];
}
The detailTextLabel
is populated by the tableData
array, and this happens in the method:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
using the line of code:
cell.detailTextLabel.text = [pickerData objectAtIndex:indexPath.row];
What am I doing wrong? any suggestions on how should I do this differently? I have been programming for only a month and I'm sure this has a simple solution. Thank You in advance!