开发者

Apple Code Sample: TouchCells, How Does it Work?

I've been working on custom UITableViewCells and came across the TouchCells example from apple: TouchCells Example Project

I can't figure out how the application loads. If you look at AppDelegate.m, you see this:

- (void)applicationDidFinishLaunching:(UIApplication *)application
{
// create window and set up table view controller
detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
detailViewController.loadView;

[window addSubview:navController.view];
[window makeKeyAndVisible];
}

which would seem to load a DetailViewController.

However, when the app loads, there is a UITableViewController of type MyTableViewController loaded with the Title TouchCells. I looked at MainWindow.xib and there is no MyTableViewController (as far as I can tell).

When I put break points in

- (void)viewDidLoad
{
// load our data from a plist file inside our app bundle
NSString *path = [[NSBundle mainBundle] pathForResource:@"tableData"     ofType:@"plist"];
self.dataArray = [NSMutableArray arrayWithContentsOfFile:path];
} 

of MyTableViewController.m, the breakpoint is hit before a breakpoint in applicationDidFinishLaunching from AppDelegate.m. I guess this means the MyTableViewController is being loaded first, but I can't for the life of me figure out where that call is in the code.

Can anybody help me figure out the logical flow of the TouchCells example?

Thanks

Answer

The selected answer has the correct information in it, but开发者_如何学C the answer @Caleb provided shows how to get that information.

Thanks everyone


When applicationDidFinishLaunching is called the interface builder connections will be set already. Therefore any class that needs to be initialized will be called before applicationDidFinishLaunching. If you are wondering as to what methods are calling it follow the stack trace once your break point is hit inside of the Debug Navigator in XCode 4.

Update:

Inside of MainWindow.xib expand the Navigation Controller and you will find MyTableViewController.


Assuming you're using Xcode 4, you can click the little expansion button at the bottom of the IB dock area:

Apple Code Sample: TouchCells, How Does it Work?

That'll let you see the objects contained in the navigation controller, like this:

Apple Code Sample: TouchCells, How Does it Work?

Now you can see that a MyTableViewController is created as the navigation controller's root controller when the main nib is loaded. Another way to do this is to use the Editor->Reveal in Document Structure command.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜