gpt4 book ai didi

iphone - 在 View 之间传递 IndexPath

转载 作者:行者123 更新时间:2023-11-28 23:12:58 26 4
gpt4 key购买 nike

我正在尝试将我的 subview 的索引路径传递到我的主视图。我通过我已经设置的委托(delegate)和协议(protocol)来执行此操作,我只是稍微编辑了我调用的方法以接受索引路径..所以一切似乎都正常工作但是当我从两个 View 执行 NSLog 时我得到下面的输出在我的终端..我想知道“0x4e1fdc0”在输出中代表什么剂量?那是内存指针还是什么?

此外,现在我在主视图中有了选定的索引路径,如果用户决定返回 subview ,我该如何将其传递回 subview ?我需要创建一个新的委托(delegate)/协议(protocol)来传递信息吗?或者我可以用另一种方式做吗..

2011-09-28 15:02:13.672 Code[14139:207] First View <NSIndexPath 0x4e1fdc0> 2 indexes [0, 0]
2011-09-28 15:02:13.673 Code[14139:207] Second View <NSIndexPath 0x4e1fdc0> 2 indexes [0, 0]

最佳答案

是的,那是内存指针,NSIndexPath 只是嵌套数组集合树中节点的路径,因此 0, 0, 表示数组 1 中的位置 0,然后是数组 2 中的位置 0。

NSIndexPath reference

您可以使用 Dependency Injection 将其传递给 subview 所以基本上只是在你的 subview 上声明:

"MyFile.h"
@property (nonatomic, retain) NSIndexPath *myPath;

"MyFile.m"

@synthesize myPath;

"MainView.m"
// After allocating the subview, or whenever you are going to show the subView
[mySubView setIndexPath:myPath];

关于iphone - 在 View 之间传递 IndexPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7577594/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com