Ios 如何将uitableviewcell数据填充到其他类?

Ios 如何将uitableviewcell数据填充到其他类?,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我的代码片段// - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // [tableView deselectRowAtIndexPath:indexPath animated:YES]; if(indexPath.section == 0) { if(indexPath.row == 1) { WebServiceHand

我的代码片段//

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// [tableView deselectRowAtIndexPath:indexPath animated:YES];

if(indexPath.section == 0)
{
    if(indexPath.row == 1)
    {
        WebServiceHandler *handler = [[WebServiceHandler alloc]init];

        handler.requestType = eSuburb;

        NSMutableURLRequest *searchDetailsRequest = [Service parseGetSuburb:nil];

        NSLog(@"user details request of str== %@",searchDetailsRequest);

        [handler placeWebserviceRequestWithString:searchDetailsRequest Target:self Selector:@selector(getListOfSuburb:)];


    }

响应后,它跳转到另一个类,其中包含所有it数据的列表,在所有这些数据中,我想用它填充一个用户选择的数据,不确定您是如何执行此操作的,但下面是如何使用segues的。在本例中,我的每个表格单元格都在NSMutableDictionary中包含它们的相关信息。接收视图控制器具有NSMutableDictionary属性以接收所有发送的数据。最后两行创建一个ViewController对象,其Dictionary属性等于从表视图中选定单元格发送的字典

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    NSString *identifier = segue.identifier;

    if ([identifier isEqualToString:@"SegueName"]) {
        // first get data
        NSIndexPath *selectedIndexPath = self.tableView.indexPathForSelectedRow;
        NSMutableDictionary *cellData   = self.aDictionary[selectedIndexPath.row];

        ViewController *nextViewController = segue.destinationViewController;
        nextViewController.aDictionary = cellData;
    }
}

我建议不要在这里使用回调方法。这不是实现这一目标的正确方式

根据我的理解,您要做的是,一旦用户选择了一行,您希望将所选行的数据传递回viewcontroller(假设为“vcA”),后者调用了带有tableview的数据(“vcB”)


如果是这样,您应该创建一个协议,然后使用一个委托通知viewcontroller“vcA”有关选择事件的信息,从而按照@Inertatic的建议传递所需的数据。

您能提供更多信息吗data@bhavyakothari我只有一个,-(UITableView单元格*)tableView:(UITableView*)tableView单元格for row索引路径:(NSIndexPath*)indexPath{static NSString*CellIdentifier=@“Cell”;UITableViewCell*Cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];if(Cell==nil){Cell=[[UITableViewCellAlloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];cell.accessoryType=UITableViewCellAccessoryNone;}cell.textLabel.text=[getDatafromSearch objectAtIndex:indexPath.row];返回单元格;}我把我所有的数据都放到了一个单元格里,现在我要做的就是按用户将选定的数据传递给另一个类别的调用单元格。谢谢你的评论,当用户点击一个单元格时,应该只传递给另一个类别的调用单元格。在你的tableview中,当用户选择某个单元格时,你希望应用程序移动到下一个视图,并使用其中的数据单元格点击,对吗?不是到下一个视图,实际上是到调用它的上一个视图,提前感谢返回到表视图后,更新所需的单元格,然后用所需数据重新加载表视图。-(void)重新加载RowsatindExpaths:(NSArray*)InExpaths with RowAnimation:(UITableViewRowAnimation)动画查看此链接:。您可能想看看如何创建代理协议,但我仍然不能100%确定如何设置所有内容。请特别查看清单3-2。很抱歉,我帮不上什么忙。是的,您的方法是正确的,我的方法也是正确的。但我不使用故事板,因为我是iOS的新手,对creatin不太了解g代表。谢谢@aish。如果您能为我提供一些帮助以确保代表方法,我会很高兴在这方面为您提供帮助。协议和代表确实需要一些理解……请查看此内容,如果您仍然需要帮助,请告诉我。我很乐意帮助……)