Objective-CでのTips UITableViewControllerのimplements

UITableViewControllerのimplementsを忘れるのでメモついでに。

#import "MyClass.h"

@implementation MyClass
@synthesize items;

// 独自の拡張メソッド
-(id) initWithTableObject:(UITableViewController *)tableView{
    
    items = [[NSMutableArray alloc]init];
    [items addObject:@"DATA ONE"];
    [items addObject:@"DATA TWO"];
    
    return self;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
// 行数の配列
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [items count];
}
// 初期データ
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
    cell.textLabel.text = [items objectAtIndex:indexPath.row];
    return cell;
}
// セルをクリックしたとき
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    /*
    detailViewController * detail = [[detailViewController alloc]initWithNibName:@"detailViewController" bundle:nil];
    detail.title = [d objectAtIndex:indexPath.row];
    [self.navigationController pushViewController:detail animated:YES];
    [detail release];
    */
}
@end