开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜