I feel like it has already been confirmed. The console displays
2012-10-25 13:31:28.916 Newsroom[3457:c07] channel items 10
before pressing the button and displays
2012-10-25 15:24:29.722 Newsroom[4590:c07] channel items 0
after pressing the button. That tells me that blank data is being put in after the button press.
Those log messages don't occur in isolation. There are messages that come before each one, and messages that come after. Context is crucial.
Some of the log messages occur due to parsing of XML retrieved from a URL asynchronously. The URL isn't going to be retrieved, and the XML isn't going to be parsed, until some time after the URL connection begins loading data. That's what asynchronously means: not at the same time.
The loading of the URL is started by the
initWithStyle: method of the ListViewController class. Until the XML has been received and parsed, the RSSChannel object which is the underlying source for the tableView, will either be nil or hold no data. This sould be evident by looking at the order of log messages. In short, by seeing the complete context.
If the "channel items 0" log messages comes before a series of log messages from the XML parsing, then it's evidence that the table is trying to load data when no data is available (nil RSSChannel). If the "channel items 0" message comes after the XML parsing messages, it's evidence of something else entirely. Without seeing all the evidence, in correct order, it's impossible to determine what's happening. The order of messages in the log is part of the evidence of what's happening; it shows you
when something happens.
The "channel items 10" message is most likely due to this code, hilited in red:
Code:
@implementation KFBAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[KFBViewController alloc] initWithNibName:@"KFBViewController" bundle:nil];
[COLOR="Red"] ListViewController *lvc = [[ListViewController alloc]initWithStyle:UITableViewStylePlain];
[/COLOR] WebViewController *wvc = [[WebViewController alloc]init];
[lvc setWebViewController:wvc];
ActionAlertsViewController *avc = [[ActionAlertsViewController alloc]initWithStyle:UITableViewStylePlain];
[avc setWebViewController:wvc];
MarketUpdatesViewController *mvc = [[MarketUpdatesViewController alloc]initWithStyle:UITableViewStylePlain];
[mvc setWebViewController:wvc];
self.window.rootViewController = self.viewController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
I have no idea what the intent or purpose of this code is.
What this does is make several different view controllers, assign them all the same WebViewController object, then do nothing else with them. The variabls lvc, wvc, avc, and mvc are local variables. The objects are not stored into ivars, nor are they given as parameters to any other object which might keep them around. They're just alloc'ed, init'ed, given a WebViewController, then promptly forgotten (released, under ARC; leaked, under manual retain/release).
One hypothesis is that you believe these objects are kept alive, and are used in the
KFBViewController class. But that doesn't make sense, since that class has this:
Code:
- (IBAction)gotoPublicAffairs
{
[COLOR="red"] ListViewController *publicAffairs = [[ListViewController alloc] initWithNibName:nil bundle:nil];
[/COLOR] publicAffairs.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
// [self presentModalViewController:publicAffairs animated:YES];
[self presentViewController:publicAffairs animated:YES completion:nil];
}
The red-hilited line clearly shows another ListViewController being made (this time without being given a WebViewController), and that ListViewController is then presented. This one is almost certainly the origin of the "channel items 0" log message, for the likely reason that the table view will be asked to draw itself almost immediately, but there is almost no chance that the URL with the XML data will be loaded by that time.
Another hypothesis is that you somehow think these two ListViewController objects have a shared RSSChannel, because they are instances of the same class. This is not true. Instance variables are unique to each instance of a class.
To summarize, I don't know what you're expecting the controller-creation code in
didFinishLaunchingWithOptions: to do, nor why you think it needs to be there. From what I can tell, it serves no useful purpose, because the controllers that are created are abandoned when that method returns, without ever being presented. An async operation (like loading a URL) will continue until completion, but the loaded data has no effect on the rest of the program. The data is not shared or used elsewhere, because the object that holds the data has been abandoned and is not visible to any other part of the program.
Your first post said you have a working table view in a working app, but you haven't shown any code from that. Without seeing that code, and thus seeing how that one actually works, there's no way for anyone here to tell you what differs between the one that works and the one that doesn't. All anyone can do is point at problems in the posted code.
And since the last code that was posted definitely had errors, all we can do is guess about how you fixed the previous problems, and what the code you're currently running looks like.