ReCall NSArray in RootViewController
I use original method XML data can show in rootviewcontroller TableView. When i use New Procedure it show the table only no data. How can i show the data in New Method?
Original Method
- appDelegate.m (setup XML & load the data)
- rootviewController.m (use nsarray & load the data into table view)
New Method
- appDelegate.m (setup XML & load the data)
- mainviewController.m (Setup up UIVEW & button key), (when button press, go to rootviewcontroller.m)
- rootviewController.m (use nsarray & load the data into table view)
appDeleagte.m
- (void)addbookToList:(NSArray *)books {
[self.rootViewController in开发者_如何转开发sertBooks:books];
mainviewcontroller.h
#import <UIKit/UIKit.h>
@class RootViewController;
@interface MainViewController : UIViewController {
IBOutlet RootViewController *rvController;
}
- (IBAction) startButton;
@end
mainviewcontroller.m
-(IBAction)startPage {
rvController = [[RootViewController alloc] initWithNibName:@"RootView" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:rvController animated:YES];
rootviewcontroller.m
- (void)viewDidLoad {
[super viewDidLoad];
self.bookList = [NSMutableArray array];
self.tableView.rowHeight = 60.0;
[self addObserver:self forKeyPath:@"bookList" options:0 context:NULL];
}
If you call addBookToList:
in your app delegate at a time that the root view controller doesn't yet exist, nothing will happen (sending message to nil). Store the books array, and pass it to your root view controller after you've created it, but before you push it onto the stack in your navigation controller.
精彩评论