Frage

Ich war ziemlich gut darin, meine Xcode OBJ-C-Fehler zu beheben, aber dieser hat mich ratlos:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
 if ([[tableList objectAtIndex:indexPath.row] isEqual:@"Standard"]) {
  [StandardSetupViewController *standard = [[StandardSetupViewController alloc] initWithNibName:@"StandardSetupViewController" bundle:nil]]; 

// ERROR OCCURS HERE:
// error: expected ':' before '*' token
// confused by earlier errors, bailing out

  [standard setTitle:@"Standard"];
  [self.navigationController pushViewController:standard animated:YES];
  [standard release];
 }
}

Ich habe den Code aus einem Video -Tutorial auf YouTube unter abgeholt http://www.youtube.com/watch?v=9ozwoetfei0, und dann mehrere Fehler in der Codierung behoben, indem Sie sie dagegen überprüfen Beginn der iPhone -Entwicklung und Beispiel -Apple -Quellcode. Ich habe doppelt überprüft, um sicherzustellen, dass der Fehler nicht auf der Seite #import ist. Ich veröffentliche die Codierung, die früher im obigen Snippet auftritt, falls Sie der Meinung sind, dass der Fehler weiter nach oben auftritt:

#import "RootViewController.h"

@implementation RootViewController

@synthesize fetchedResultsController, managedObjectContext;

- (void)viewDidLoad {
 self.title = @"Setting Up"; 
 tableList = [[NSMutableArray alloc] init];
 [tableList addObject:@"Standard"];
 [tableList release];
    [super viewDidLoad];

 // Set up the edit and add buttons.
    self.navigationItem.leftBarButtonItem = self.editButtonItem;

    UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject)];
    self.navigationItem.rightBarButtonItem = addButton;
    [addButton release];

 NSError *error;
 if (![[self fetchedResultsController] performFetch:&error]) {
  // Handle the error...
 }

}

- (void)didReceiveMemoryWarning {
 // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

 // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
 // Release anything that can be recreated in viewDidLoad or on demand.
 // e.g. self.myOutlet = nil;
}


#pragma mark Table view methods

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
 return [tableList count]; 
}

// Customize the appearance of table view cells.
- (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];
    }

 // Configure the cell.

 cell.textLabel.text = [[tableList objectAtIndex:indexPath.row] retain];
 [cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];

    return cell;

}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
 if ([[tableList objectAtIndex:indexPath.row] isEqual:@"Standard"]) {
  [StandardSetupViewController *standard = [[StandardSetupViewController alloc] initWithNibName:@"StandardSetupViewController" bundle:nil]]; 

// ERROR OCCURS HERE:
// error: expected ':' before '*' token
// confused by earlier errors, bailing out

  [standard setTitle:@"Standard"];
  [self.navigationController pushViewController:standard animated:YES];
  [standard release];
 }
}

Vielen Dank! Steve (Wer ist "verwirrt" und denkt auch daran, auch auszutreten!)

War es hilfreich?

Lösung

Du wickelst deine nicht ein StandardSetupViewController Mit Klammern war das das Problem.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    if ([[tableList objectAtIndex:indexPath.row] isEqual:@"Standard"]) {
        StandardSetupViewController *standard = [[StandardSetupViewController alloc] initWithNibName:@"StandardSetupViewController" bundle:nil];

        [standard setTitle:@"Standard"];
        [self.navigationController pushViewController:standard animated:YES];
        [standard release];
    }
}

Deine:

[StandardSetupViewController *standard = [[StandardSetupViewController alloc] initWithNibName:@"StandardSetupViewController" bundle:nil]];

Sollte sein:

StandardSetupViewController *standard = [[StandardSetupViewController alloc] initWithNibName:@"StandardSetupViewController" bundle:nil];
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top