在视图之间传递 IndexPath

发布于 2024-12-06 20:56:47 字数 469 浏览 3 评论 0原文

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

现在我在主视图中已经选择了索引路径,如果用户决定返回子视图,我如何将其传递回子视图?我是否需要制定新的委托/协议来转发信息?或者我可以用另一种方式来做吗..

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]

I am trying to pass the indexpath of my subview over to my main view. I am doing this through delegates and protocols that I have alread set up, I have just slightly edited the method I call to accept the indexpath.. so everything seems to work correctly however when I do the NSLog from both views I get the output below in my terminal.. I would like to know what dose the "0x4e1fdc0" represent in the output? is that a memory pointer or something?

Also now that I have the selected indexpath in my mainview, if the user decides to go back to the subview how can i pass it back to the subview? do I need to make a new delegate/protocol to pass the information forward? or can I do it another way..

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]

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

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

发布评论

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

评论(1

等风也等你 2024-12-13 20:56:47

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

NSIndexPath参考

您可以使用依赖注入将其传递给子视图,所以基本上只需在你的子视图:

"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];

Yes that is the memory pointer, a NSIndexPath is just a path to a node in a tree of nested array collections, so 0, 0, means position 0 in array 1 and then position 0 in array 2.

NSIndexPath reference

You can pass it to the subview using Dependency Injection so basically just declare this on your 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];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文