2012-05-02 20 views
-2

'不完全な実装'の警告が表示されていますが、ソースファイルと比較した理由がわかりません。警告をコメントアウトしました。'不完全な実装'の警告

ItemsViewController.mのマイバージョン

#import "ItemsViewController.h" 
    #import "BNRItemStore.h" 
    #import "BNRItem.h" 

    @implementation ItemsViewController //Incomplete implementation 

    - (id)init 
    { 
     // Call the superclass's designated initializer 
     self = [super initWithStyle:UITableViewStyleGrouped]; 
     if (self) { 
     UINavigationItem *n = [self navigationItem]; 

     [n setTitle:@"Homepwner"]; 

     // Create a new bar button item that will send 
     // addNewItem: to ItemsViewController 
     UIBarButtonItem *bbi = [[UIBarButtonItem alloc] 
           initWithBarButtonSystemItem:UIBarButtonSystemItemAdd 
           target:self 
           action:@selector(addNewItem:)]; 

     // Set this bar button item as the right item in the navigationItem 
     [[self navigationItem] setRightBarButtonItem:bbi]; 

     [[self navigationItem] setLeftBarButtonItem:[self editButtonItem]]; 
     } 
     return self; 
    } 

    - (IBAction)addNewItem:(id)sender 
    { 
     // Create a new BNRItem and add it to the store 
     BNRItem *newItem = [[BNRItemStore defaultStore] createItem];//No known class method for selector 'defaultStore' 
     // Incompatible pointer types initializing 'BNRItem*__strong' with an expression of 'NSArray' 

     // Figure out where that item is in the array 
     int lastRow = [[[BNRItemStore defaultStore] allItems] indexOfObject:newItem]; //No known class method for selector 'defaultStore' 

     NSIndexPath *ip = [NSIndexPath indexPathForRow:lastRow inSection:0]; 

     // Insert this new row into the table. 
     [[self tableView] insertRowsAtIndexPaths:[NSArray arrayWithObject:ip] 
           withRowAnimation:UITableViewRowAnimationTop]; 
    } 

    - (id)initWithStyle:(UITableViewStyle)style 
    { 
     return [self init]; 
    } 

    - (void)viewWillAppear:(BOOL)animated 
    { 
     [super viewWillAppear:animated]; 
     [[self tableView] reloadData]; 
    } 

    - (void)tableView:(UITableView *)tableView 
    moveRowAtIndexPath:(NSIndexPath *)fromIndexPath 
      toIndexPath:(NSIndexPath *)toIndexPath 
    { 
     [[BNRItemStore defaultStore] moveItemAtIndex:[fromIndexPath row] //No known class method for selector 'defaultStore' 
              toIndex:[toIndexPath row]]; 
    } 

    - (void)tableView:(UITableView *)aTableView 
    didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     DetailViewController *detailViewController = [[DetailViewController alloc] init]; 

     NSArray *items = [[BNRItemStore defaultStore] allItems];//No known class method for selector 'defaultStore' 
     BNRItem *selectedItem = [items objectAtIndex:[indexPath row]]; 

     // Give detail view controller a pointer to the item object in row 
     [detailViewController setItem:selectedItem]; 

     // Push it onto the top of the navigation controller's stack 
     [[self navigationController] pushViewController:detailViewController 
              animated:YES]; 
    } 



    -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)io 
    { 
     if ([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPad) { 
     return YES; 
     } else { 
     return (io==UIInterfaceOrientationPortrait); 
     } 
    } 

    - (void)tableView:(UITableView *)tableView 
    commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
    forRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     // If the table view is asking to commit a delete command... 
     if (editingStyle == UITableViewCellEditingStyleDelete) 
     { 
     BNRItemStore *ps = [BNRItemStore defaultStore];//No known class method for selector 'defaultStore' 
     NSArray *items = [ps allItems]; 
     BNRItem *p = [items objectAtIndex:[indexPath row]]; 
     [ps removeItem:p]; 

     // We also remove that row from the table view with an animation 
     [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] 
         withRowAnimation:UITableViewRowAnimationFade]; 
     } 
    } 

    - (NSInteger)tableView:(UITableView *)tableView 
    numberOfRowsInSection:(NSInteger)section 
    { 
     return [[[BNRItemStore defaultStore] allItems] count];//No known class method for selector 'defaultStore' 
    } 
    - (UITableViewCell *)tableView:(UITableView *)tableView 
      cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     // Create an instance of UITableViewCell, with default appearance 
     // Check for a reusable cell first, use that if it exists 
     UITableViewCell *cell = 
     [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"]; 

     // If there is no reusable cell of this type, create a new one 
     if (!cell) { 
     cell = [[UITableViewCell alloc] 
       initWithStyle:UITableViewCellStyleDefault 
       reuseIdentifier:@"UITableViewCell"]; 
     } 
     // Set the text on the cell with the description of the item 
     // that is at the nth index of items, where n = row this cell 
     // will appear in on the tableview 
     BNRItem *p = [[[BNRItemStore defaultStore] allItems]//No known class method for selector 'defaultStore' 
        objectAtIndex:[indexPath row]]; 
     [[cell textLabel] setText:[p description]]; 
     return cell; 
    } 

    @end 

Original source version of ItemsViewController.m 

#import "ItemsViewController.h" 
#import "BNRItemStore.h" 
#import "BNRItem.h" 

@implementation ItemsViewController 
- (id)init 
{ 
    // Call the superclass's designated initializer 
    self = [super initWithStyle:UITableViewStyleGrouped]; 
    if (self) { 
     UINavigationItem *n = [self navigationItem]; 

     [n setTitle:@"Homepwner"]; 

     // Create a new bar button item that will send 
     // addNewItem: to ItemsViewController 
     UIBarButtonItem *bbi = [[UIBarButtonItem alloc] 
         initWithBarButtonSystemItem:UIBarButtonSystemItemAdd 
              target:self 
              action:@selector(addNewItem:)]; 

     // Set this bar button item as the right item in the navigationItem 
     [[self navigationItem] setRightBarButtonItem:bbi]; 

     [[self navigationItem] setLeftBarButtonItem:[self editButtonItem]]; 
    } 
    return self; 
} 
- (IBAction)addNewItem:(id)sender 
{ 
    // Create a new BNRItem and add it to the store 
    BNRItem *newItem = [[BNRItemStore defaultStore] createItem]; 

    // Figure out where that item is in the array 
    int lastRow = [[[BNRItemStore defaultStore] allItems] indexOfObject:newItem]; 

    NSIndexPath *ip = [NSIndexPath indexPathForRow:lastRow inSection:0]; 

    // Insert this new row into the table. 
    [[self tableView] insertRowsAtIndexPaths:[NSArray arrayWithObject:ip] 
          withRowAnimation:UITableViewRowAnimationTop]; 
} 
- (id)initWithStyle:(UITableViewStyle)style 
{ 
    return [self init]; 
} 

- (void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 
    [[self tableView] reloadData]; 
} 


- (void)tableView:(UITableView *)tableView 
    moveRowAtIndexPath:(NSIndexPath *)fromIndexPath 
      toIndexPath:(NSIndexPath *)toIndexPath 
{ 
    [[BNRItemStore defaultStore] moveItemAtIndex:[fromIndexPath row] 
             toIndex:[toIndexPath row]]; 
} 

- (void)tableView:(UITableView *)aTableView 
    didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    DetailViewController *detailViewController = [[DetailViewController alloc] init]; 

    NSArray *items = [[BNRItemStore defaultStore] allItems]; 
    BNRItem *selectedItem = [items objectAtIndex:[indexPath row]]; 

    // Give detail view controller a pointer to the item object in row 
    [detailViewController setItem:selectedItem]; 

    // Push it onto the top of the navigation controller's stack 
    [[self navigationController] pushViewController:detailViewController 
              animated:YES]; 
} 

- (void)tableView:(UITableView *)tableView 
    commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
    forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // If the table view is asking to commit a delete command... 
    if (editingStyle == UITableViewCellEditingStyleDelete) 
    { 
     BNRItemStore *ps = [BNRItemStore defaultStore]; 
     NSArray *items = [ps allItems]; 
     BNRItem *p = [items objectAtIndex:[indexPath row]]; 
     [ps removeItem:p]; 

     // We also remove that row from the table view with an animation 
     [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] 
         withRowAnimation:UITableViewRowAnimationFade]; 
    } 
} 

- (NSInteger)tableView:(UITableView *)tableView 
numberOfRowsInSection:(NSInteger)section 
{ 
    return [[[BNRItemStore defaultStore] allItems] count]; 
} 
- (UITableViewCell *)tableView:(UITableView *)tableView 
     cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // Create an instance of UITableViewCell, with default appearance 
    // Check for a reusable cell first, use that if it exists 
    UITableViewCell *cell = 
     [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"]; 

    // If there is no reusable cell of this type, create a new one 
    if (!cell) { 
     cell = [[UITableViewCell alloc] 
        initWithStyle:UITableViewCellStyleDefault 
        reuseIdentifier:@"UITableViewCell"]; 
    } 
    // Set the text on the cell with the description of the item 
    // that is at the nth index of items, where n = row this cell 
    // will appear in on the tableview 
    BNRItem *p = [[[BNRItemStore defaultStore] allItems] 
            objectAtIndex:[indexPath row]]; 
    [[cell textLabel] setText:[p description]]; 
    return cell; 
} 
@end 

ItemsViewController.h(私はひどくそれを読んでおりません場合)あなたの.mファイルで2つのメソッドを実装していない

#import <Foundation/Foundation.h> 
#import "DetailViewController.h" 

@interface ItemsViewController : UITableViewController 
{ 
    IBOutlet UIView *headerView; 
} 

-(UIView *)headerView; 
-(IBAction)addNewItem:(id)sender; 
-(IBAction)toggleEditingMode:(id)sender; 

@end 
+2

警告の詳細が不足しているかを表示します。 –

+1

ヘッダーファイルを参照する必要があります。不完全な実装は、ヘッダーで宣言したメソッドまたは必要なプロトコルメソッドを実装していないためです。 – Joe

+0

私は決してこれで詳細を見たことがありません。ヘッダーにメソッドを定義して実装するのを忘れたときに起こります。 –

答えて

1

-(UIView *)headerView; 
-(IBAction)toggleEditingMode:(id)sender; 

警告が表示されます。

いずれの場合でも、ビルド結果ウィンドウでは、黄色のアイコンをクリックすると警告アイコンが表示されます。黄色いアイコンをクリックすると、実装に欠落している方法が詳細に表示されますファイル。

+0

それはそれを修正しました。どうもありがとうございました! – pdenlinger

0

次の2つのメソッドを実装しているように見えません。

-(UIView *)headerView; 
-(IBAction)toggleEditingMode:(id)sender; 
関連する問題