我的 XMLAppDelegate.m 文件中有以下代码:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[self.window makeKeyAndVisible];
self.products = [NSMutableArray array];
XMLViewController *viewController = [[XMLViewController alloc] init];
viewController.entries = self.products; // 2. Here my Array is EMPTY. Why?
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:productData]];
self.XMLConnection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
NSAssert(self.XMLConnection != nil, @"Failure to create URL connection.");
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}
- (void)handleLoadedXML:(NSArray *)loadedData {
[self.products addObjectsFromArray:loadedData]; // 1. here I get my Data (works fine)
XMLViewController *viewController = [[XMLViewController alloc] init];
[viewController.tableView reloadData];
}
我标记了问题。是否有可能将加载的数据(loadedData)传递给 applicationDidFinishLaunching:?
提前致谢..