Im new to iOS programming and I’m trying to get the table view running with my app but I can’t find any solid information as to why the app keeps aborting. here is the code from the delegate file, can anyone tell me what I’m doing wrong thats causing the error?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
listTopics = [NSMutableArray arrayWithCapacity:8];
Topics *topic = [[Topics alloc]init];
topic.topic = @"Movies";
[listTopics addObject:topic];
topic = [[Topics alloc]init];
topic.topic = @"Games";
[listTopics addObject:topic];
topic = [[Topics alloc]init];
topic.topic = @"TV";
[listTopics addObject:topic];
topic = [[Topics alloc]init];
topic.topic = @"Cars";
[listTopics addObject:topic];
topic = [[Topics alloc]init];
topic.topic = @"Actors";
[listTopics addObject:topic];
topic = [[Topics alloc]init];
topic.topic = @"Sports";
[listTopics addObject:topic];
topic = [[Topics alloc]init];
topic.topic = @"Brands";
[listTopics addObject:topic];
topic = [[Topics alloc]init];
topic.topic = @"Music";
[listTopics addObject:topic];
topic = [[Topics alloc]init];
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
TopicsViewController *topicsViewController = [[navigationController viewControllers]objectAtIndex:0];
topicsViewController.listTopics = listTopics;
return YES;
}
I assume you want to show a navigation controller which has table view controller as a root view controller, which is TopicsViewController for you.
In your
method you need to set the rootViewController property of your window. You can not get it because you havent set yet. After that you need to make it visible. The following code should help you
please note that, if you do not use ARC you need to release the objects you have called alloc on them.