错误:'#' 之前应有标识符代币

发布于 2025-01-02 07:16:51 字数 750 浏览 4 评论 0原文

在搜索这个编译时错误后,我发现了很多关闭的错误,但通常带有“)”或“}”,这似乎不是我面临的问题。

我正在开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

李白 2025-01-09 07:16:51

在您的项目中搜索 # 字符,通常是缺少终止符或在此之前出现语法错误。

Do a search through your project for the # character it's usually a missing terminator or syntax error before that.

羁绊已千年 2025-01-09 07:16:51

查看 .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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文