PeterK
PeterK

Reputation: 4301

Load/unload new views in Objective-C

I am currently testing this environment and would like to ask about the best strategy loading/unloading for a multiview application.

The app i am playing around with should have the following:

Main: a normal view with 5 x buttons (Play, Leaderboard, Properties, Instructions and an "i" button for about)

The Properties is a tableView where each cell opens up a new tableView with the actual properties.

What is the best strategy from a flexibility and memory point of view to do this?

Upvotes: 0

Views: 539

Answers (1)

David
David

Reputation: 2871

Store the extra views in their own nib-files. Load them in when needed using +[NSBundle loadNibNamed:@"nibFileName" owner:self]. Replace self with whatever object that you want the nib's "File's Owner" to point to. (Usually it would be self, though, since it would be the view's controller whose job it was to create the nib; and the controller is also typically what you want as your File's Owner.)

Disclaimer: I'm basing this on my knowledge of Cocoa on the desktop, but I'm pretty sure nib-files work the same on the iPhone.

Upvotes: 1

Related Questions