开发者

How can we access the object in stack of different classes in IPhone development?

开发者 https://www.devze.com 2023-04-01 12:48 出处:网络
I am using navigation based appli开发者_StackOverflow社区cation. In RootViewController I am initializing an array object and calling another(Pushing it into stack) class Test in which we have to use t

I am using navigation based appli开发者_StackOverflow社区cation. In RootViewController I am initializing an array object and calling another(Pushing it into stack) class Test in which we have to use that array value that i initialized in the RootViewController. How can we access ? Thanks in Advance..


You can access the parent view controllers from any other pushed view controller. The very first element in the collection of parents is the root view controller. Access this element, cast it to your specific implementation, then access your array object from it. So something like:

UIViewController * rootVC = [self.navigationController.viewControllers objectAtIndex: 0];
NSArray * myArray = ((MyUIViewController *) rootVC).myArrayProperty;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号