我有一个TableViewController
转入一个TabBarViewController
.
我知道如何通过 segue 传递我的对象,而不是通过像TabBarViewController
它的标签共享这样的关系。
我怎样才能做到这一点? 从 TabView 有没有办法访问 TabBarViewControllers 成员变量?
更新:
到目前为止,这就是我解决问题的方法,但我并不热衷于使用 AppDelegate 来做到这一点......
将以下内容添加到WhateverYouNamedYourAppDelegate.h
@class myObjectIWantToPass;
@property (strong, nonatomic) myObjectIWantToPass *object;
然后将以下内容添加到您想要传递的数据的视图类文件中。如果您计划将其传递到另一个视图,我将假设您知道如何在此文件中设置您的对象。
WhateverYouNamedYourAppDelegate *appDelegate =
(WhateverYouNamedYourAppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.object = object;
然后你做一些类似的工作从目标视图类中的 appDelegate 检索对象。
WhateverYouNamedYourAppDelegate *appDelegate = (WhateverYouNamedYourAppDelegate *)[[UIApplication sharedApplication] delegate];
object = appDelegate.object;