I'm looking to find a way to add the didSelectRowAtIndexPath:
'cell name' that is selected in the table through the didDismissWithButtonIndex:
method:
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
Database *currentStore = [DBList objectAtIndex:indexPath.row];
NSString *requestStr = @"http://";
requestStr = [requestStr stringByAppendingString:hostTextField.text];
requestStr = [requestStr stringByAppendingString:@":8080/compfile2.php?password="];
requestStr = [requestStr stringByAppendingString:passwordTextField.text];
requestStr = [requestStr stringByAppendingString:@"&db=latinbites"];
requestStr = [requestStr stringByAppendingString:currentStore];
}
Obviously, the
Database *currentStore = [DBList objectAtIndex:indexPath.row];
isn't correct. Is there a way I can put a string on the selected cell row?
I believe I understand what you want to achieve. Try to following code:-
No. 1 - Declare a property with NSString
@interface TableViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong) NSString * selectedCellName;
@end
No. 2 - In didSelectRowAtIndexPath
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
self.selectedCellName = cell.textLabel.text;
}
No. 3 - In didDismissWithButtonIndex, append the cell name.
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
NSString *requestStr = @"http://";
requestStr = [requestStr stringByAppendingString:hostTextField.text];
requestStr = [requestStr stringByAppendingString:@":8080/compfile2.php?password="];
requestStr = [requestStr stringByAppendingString:passwordTextField.text];
requestStr = [requestStr stringByAppendingString:@"&db=latinbites"];
requestStr = [requestStr stringByAppendingString:self.selectedCellName];
}
}