// // <%= @class_name %>List.m // PureMVC_ObjectiveC // // Created by <%= @developer.capitalize %> on <%= @created_on %> // Copyright(c) <%= Time.now.year %>, All rights reserved. // #import "<%= @class_name %>List.h" #define USER_CELL_ID @"<%= @class_name %>CellID" @implementation <%= @class_name %>List @synthesize <%= @project_name %>s, delegate; -(id)init { return [super initWithStyle:UITableViewStylePlain]; } - (void)loadView { [super loadView]; self.<%= @project_name %>s = [NSMutableArray array]; //self.navigationItem.leftBarButtonItem = self.editButtonItem; self.navigationItem.title = @"<%= @class_name %>s"; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(new<%= @class_name %>)]; } -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [delegate <%= @project_name %>ListAppeared]; } -(void)reload<%= @class_name %>s:(NSMutableArray *)_<%= @project_name %>s { self.<%= @project_name %>s = _<%= @project_name %>s; [self.tableView reloadData]; } - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { <%= @class_name %>VO *<%= @project_name %>VO = [[<%= @project_name %>s objectAtIndex:indexPath.row] retain]; [<%= @project_name %>s removeObjectAtIndex:indexPath.row]; [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; [delegate delete<%= @class_name %>Selected:<%= @project_name %>VO]; [<%= @project_name %>VO release]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *<%= @project_name %>Cell = [tableView dequeueReusableCellWithIdentifier:USER_CELL_ID]; if (<%= @project_name %>Cell == nil) { <%= @project_name %>Cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:USER_CELL_ID] autorelease]; <%= @project_name %>Cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } <%= @class_name %>VO *<%= @project_name %>VO = [<%= @project_name %>s objectAtIndex:indexPath.row]; <%= @project_name %>Cell.textLabel.text = [<%= @project_name %>VO givenName]; return <%= @project_name %>Cell; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [<%= @project_name %>s count]; } -(void)new<%= @class_name %> { [delegate new<%= @class_name %>Selected]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [delegate <%= @project_name %>Selected:[<%= @project_name %>s objectAtIndex:indexPath.row]]; } - (void)dealloc { self.<%= @project_name %>s = nil; self.delegate = nil; [super dealloc]; } @end