错误:'#' 之前应有标识符代币
在搜索这个编译时错误后,我发现了很多关闭的错误,但通常带有“)”或“}”,这似乎不是我面临的问题。
我正在开发一个 iPhone 应用程序,并且在 UINavigationViewController
中有一个 UITableView
。我想选择一个表格单元格并将新视图推送到导航堆栈上。我能够将通用 UIViewController
推入堆栈,但是当我使用此 DetailViewController
(通过 File->New File...->UIViewController 子类创建w/ XIB 文件,我收到此错误:“错误:'#' 标记之前的预期标识符”
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
有人可以帮忙吗?谢谢!
After searching for this compile-time error, I found a lot of closed ones, but usually with ')' or '}' which didn't seem to be the problem I'm facing.
I'm developing an iPhone app and have a UITableView
within a UINavigationViewController
. I'd like to select a table cell and push a new view onto the navigation stack. I'm able to push a generic UIViewController
onto the stack, but when I use this DetailViewController
(created via File->New File...->UIViewController subclass w/ XIB file, I get this error: "error: expected identifier before '#' token"
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
Can someone please help? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的项目中搜索
#
字符,通常是缺少终止符或在此之前出现语法错误。Do a search through your project for the
#
character it's usually a missing terminator or syntax error before that.查看 .h 和 .m 文件的顶部,您很可能错误地在那里输入了一个字符。它看起来像
s#import "..."
或类似的东西Look at the top of your .h and .m files, you've most probably mistakenly inputted a character there. It will look like
s#import "..."
or something like that