簡單的問題...我對我的代碼有一些評論,並刪除它們,並得到一個錯誤。幾個小時後,我到達了源頭。Xcode上奇怪的編譯錯誤
此代碼:
switch (indexPath.row) {
case 0:
NSLog(@"case 0");
break;
case 1: // Clients
NSLog(@"case 1");
ViewClientListTableController *viewListTableController = [[ViewClientListTableController alloc] init];//]WithNibName:@"BrowseViewController" bundle:nil];
viewListTableController.managedObjectContext = self.managedObjectContext;
[self.navigationController pushViewController:viewListTableController animated:YES];
//[self.navigationController setNavigationBarHidden:NO];
[viewListTableController release];
break;
}
這下一個,(由剛取出的NSLog(@ 「情況1」);)不工作:
switch (indexPath.row) {
case 0:
NSLog(@"case 0");
break;
case 1: // Clients
ViewClientListTableController *viewListTableController = [[ViewClientListTableController alloc] init];//]WithNibName:@"BrowseViewController" bundle:nil];
viewListTableController.managedObjectContext = self.managedObjectContext;
[self.navigationController pushViewController:viewListTableController animated:YES];
//[self.navigationController setNavigationBarHidden:NO];
[viewListTableController release];
break;
}
正如你所看到的,只有NSLog線路消失了。和編譯器是給我2個錯誤:
RootViewController.m:212:錯誤:213::錯誤: '之前ViewClientListTableController'
RootViewController.m預期表達 'viewListTableController' 未申報(第一在此函數使用)
當然,一個答案是離開NSLog線,但真的......爲什麼會發生這種錯誤?
這工作。謝謝 – elcool 2010-09-30 06:21:17
太棒了!如果這是您想要接受的答案,請不要忘記點擊複選標記。 – 2010-09-30 06:28:40