开发者

Accessing array of from another view controller class

开发者 https://www.devze.com 2023-02-09 21:18 出处:网络
I am new in iPhone development and Objective-C. I have RootViewController and DetailViewController. I don\'t wanna go back to table view and select other row to show data. I want to check next data di

I am new in iPhone development and Objective-C. I have RootViewController and DetailViewController. I don't wanna go back to table view and select other row to show data. I want to check next data directly from the DetailView. But i dont know how to access that array which is defined in RootViewController. Ca开发者_开发问答n anyone please help me with that? Please give some example code because i am very new to Objective-C and iPhone development. Thanx in advance.


There are a couple ways you might pursue this. You could pass the array to the detail view controller. Alternately, and more my recommendation is that you can have your next button handler send a message back to the root controller, to have it run the detailView showing routine on the next item instead of restoring the rootview.

Assuming you have a situation where the delegate of the detailViewController is the rootViewController, you'd have a method in the root viewController like:

- (void)detailViewControllerDidAskForNext:(detailViewController *)controller {
     [self showNextDetail]; //you'd supply the showNextDetail method
}

And a method in the detailController like this, hooked to your next button.

- (IBAction)next {
    [self.delegate detailViewControllerDidAskForNext:self]; 
}

Sorry if these are too vague.

0

精彩评论

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