如何将变量传递给TabviewController?

发布于 2024-12-29 01:05:06 字数 969 浏览 4 评论 0原文

使用以下代码,我将数据发送到视图控制器,然后视图控制器根据我发送的 ID 变量检索另一组数据。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *dict = [rows objectAtIndex: indexPath.row];

    ListingsViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"tabView"];

       controller.SUBSUBCATNAME = [dict objectForKey:@"S_NAME_EN"];

    controller.SUBSUBCATNUMBER = [dict objectForKey:@"SUBCAT_ID"];
    [self.navigationController pushViewController:controller animated:YES];

}

下一个视图加载另一个列出某个国家/地区酒店的表。我想做的是在选项卡之间放置一个选项卡视图,并借助选项卡过滤酒店。例如,第一个选项卡将显示所有酒店,第二个选项卡将显示一个地区的酒店,第三个选项卡将显示另一个地区的酒店,依此类推。

我的问题是,当我将 SUBSUBCATNUMBER 发送到 tabbarcontroller 时,它会引发错误:

'NSInvalidArgumentException', reason: '-[tabView setSUBSUBCATNUMBER:]: unrecognized selector sent to instance 

如何将此 ID 发送到 tabbarcontroller,该 tabbarcontroller 会加载列出该 ID 类别中所有列表的视图控制器。

With the following code, I send data to a view controller, which then retrieves another set of data based on the ID variable that I send.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *dict = [rows objectAtIndex: indexPath.row];

    ListingsViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"tabView"];

       controller.SUBSUBCATNAME = [dict objectForKey:@"S_NAME_EN"];

    controller.SUBSUBCATNUMBER = [dict objectForKey:@"SUBCAT_ID"];
    [self.navigationController pushViewController:controller animated:YES];

}

The next view loads another table that lists hotels in a country. What I want to do is to put a tabview in between and filter hotels with the help of tabs. Forexample, the first tab will display all hotels, the second tab will display hotels in one region, the third tab another region and so on.

My problem is when I send SUBSUBCATNUMBER to tabbarcontroller, it throws an error:

'NSInvalidArgumentException', reason: '-[tabView setSUBSUBCATNUMBER:]: unrecognized selector sent to instance 

How can I send this ID to the tabbarcontroller which loads my view controller that lists all listings in that ID's category.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

很酷又爱笑 2025-01-05 01:05:06

您违反了命名规则,这就是它失败的原因。您的 ivar 名称应以小写字母开头,因此应将其称为 subSubCatNumber,或任何其他以小写字母开头的名称。将 SUBSUBCATNUMBER 更改为上面的内容,如果您愿意,甚至可以将 SUBSUBCATNUMBER 更改为,但将第一个字母小写。仅当您在某处显式调用 setSUBSUBCATNUMBER 时才将其保留为大写。

You're breaking the naming rules, which is why it's failing. Your ivar names should begin with a lowercase letter, so it should be called subSubCatNumber, or any other name, that begins with a lower case letter. Change SUBSUBCATNUMBER to the above, or even sUBSUBCATNUMBER if you wish, but make the first letter lower case. Only leave it capitalized if you explicitly call setSUBSUBCATNUMBER somewhere.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文