OBJ-C 오류를 수정하기 어려운 오류 : 예상 ':'이전 '*'Xcode의 토큰
-
05-07-2019 - |
문제
나는 Xcode OBJ-C 오류를 고치는 데 꽤 능숙했지만 이것은 나를 괴롭 혔습니다.
- (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];
}
}
YouTube의 비디오 자습서에서 코드를 선택했습니다. http://www.youtube.com/watch?v=9ozwoetfei0, 그런 다음 코딩에서 몇 가지 오류를 확인하여 코딩에서 몇 가지 오류를 수정했습니다. iPhone 개발 시작 샘플 Apple 소스 코드. #import 페이지에 오류가 없도록 두 번 확인했습니다. 오류가 더 이상 발생한다고 생각할 경우 위의 스 니펫에서 앞서 발생하는 코딩을 게시하고 있습니다.
#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];
}
}
감사! 스티브 (누가 "혼란스러워"라고 생각하고 "구제"를 생각하는 사람도!)
해결책
당신은 당신을 감싸지 않습니다 StandardSetupViewController
브래킷으로 그것은 문제였습니다.
- (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];
}
}
당신 것:
[StandardSetupViewController *standard = [[StandardSetupViewController alloc] initWithNibName:@"StandardSetupViewController" bundle:nil]];
해야한다:
StandardSetupViewController *standard = [[StandardSetupViewController alloc] initWithNibName:@"StandardSetupViewController" bundle:nil];
제휴하지 않습니다 StackOverflow