Permalink
Browse files

Add the first model and Airplane mode cell.

  • Loading branch information...
1 parent b21b08d commit f1b0b440070649fb51da6c33360afb819dfd2296 @jverkoey committed Jun 7, 2012
Showing with 21 additions and 4 deletions.
  1. +1 −1 Settings/AppDelegate.m
  2. +1 −1 Settings/RootController.h
  3. +19 −2 Settings/RootController.m
View
@@ -18,7 +18,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
- RootController* rc = [[RootController alloc] initWithNibName:nil bundle:nil];
+ RootController* rc = [[RootController alloc] init];
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:rc];
self.window.rootViewController = navController;
@@ -8,6 +8,6 @@
#import <UIKit/UIKit.h>
-@interface RootController : UIViewController
+@interface RootController : UITableViewController
@end
View
@@ -9,14 +9,25 @@
#import "RootController.h"
@interface RootController ()
+@property (nonatomic, readwrite, retain) NITableViewModel* model;
@end
@implementation RootController
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
+@synthesize model;
+
+- (id)initWithStyle:(UITableViewStyle)style {
+ self = [super initWithStyle:UITableViewStyleGrouped];
if (self) {
self.title = @"Settings";
+
+ NSMutableArray* contents =
+ [NSMutableArray arrayWithObjects:
+ [NITitleCellObject objectWithTitle:@"Airplane Mode" image:[UIImage imageNamed:@"Settings-Air"]],
+ nil];
+ // NICellFactory here allows us to take advantage of the pre-built bindings between
+ // Nimbus cells. This way we don't have to create our own factory until we absolutely need to.
+ self.model = [[NITableViewModel alloc] initWithSectionedArray:contents delegate:(id)[NICellFactory class]];
}
return self;
}
@@ -25,4 +36,10 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
return NIIsSupportedOrientation(interfaceOrientation);
}
+- (void)loadView {
+ [super loadView];
+
+ self.tableView.dataSource = self.model;
+}
+
@end

0 comments on commit f1b0b44

Please sign in to comment.