Objective c ItemsViewController.m中重复出现的问题

Objective c ItemsViewController.m中重复出现的问题,objective-c,Objective C,我在ItemsViewController.m中遇到了重复的问题,尽管我没有更改相关方法中的任何内容。之前有一些问题,我问了这么早,然后纠正了他们,但他们又出现了。没有对方法/区域进行任何更改,这再次引起了骚动。我们已经评论出了问题的领域 可能有编译器问题吗 这是文件;提前谢谢 ItemsViewController.m #import "ItemsViewController.h" #import "BNRItemStore.h" #import "BNRItem.h" @implement

我在ItemsViewController.m中遇到了重复的问题,尽管我没有更改相关方法中的任何内容。之前有一些问题,我问了这么早,然后纠正了他们,但他们又出现了。没有对方法/区域进行任何更改,这再次引起了骚动。我们已经评论出了问题的领域

可能有编译器问题吗

这是文件;提前谢谢

ItemsViewController.m

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

@implementation ItemsViewController //@end is missing in implementation context

- (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];

  DetailViewController *detailViewController = [[DetailViewController alloc]initForNewItem:YES];

  [detailViewController setItem:newItem];

  [detailViewController setDismissBlock:^{[[self tableView]reloadData];

  UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:detailViewController];

  [navController setModalPresentationStyle:UIModalPresentationFormSheet];

  [self presentViewController:navController animated:YES completion:nil];


  }

- (id)initWithStyle:(UITableViewStyle)style //use of undeclared identifier 'initWithStyle'
{
  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] initForNewItem:NO];

  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];
}



-(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];
    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 // expected '}'

此行似乎缺少块的结尾:

[detailViewController setDismissBlock:^{[[self tableView]reloadData];
应该是:

[detailViewController setDismissBlock:^{[[self tableView]reloadData]}];