预期的标识符或’(’在iOS中

我正在尝试使用Apple的iOS核心数据教程,但无法解决此错误。

我试图通过阅读这里的所有问题来解决这个问题但却无处可去 –

有任何想法吗?

#import  UINavigationController *navigationController; @interface AppDelegate : UIResponder  @property (strong, nonatomic) UIWindow *window; @property (nonatomic, retain) UINavigationController *navigationController; // expected identifier or '(' on the line above @end 

更好的解决方案 – 更改文本首选项以将ctrl-return绑定到实际换行符。

我写了一篇截图的博客文章 。


@jlehr说的是什么,但有步骤。

  1. 转到声明navigationController的行的末尾

  2. 点击ctrl-a

如果光标到达行声明window的开头,那么该行的换行符就是假的。

快速解决; 用光标在行声明window的开头,点击向下箭头 ,然后删除 ,然后返回

一直发生在我身上,因为我有深深的根深蒂固的emacs,因此,点击ctrl-return ,插入错误类型的换行符,导致编译器barf。 提交一个错误,请将它标记为欺骗,但是欺骗表示这会让用户感到沮丧。

删除此语句或更改变量名称:

 UINavigationController *navigationController; 

然后再试一次。

您在同一个类中有两个相同的变量名称。 一个作为财产,一个作为全球。

编辑:

或者你的意图是用作ivar,所以你应该使用:

 @interface AppDelegate : UIResponder { UINavigationController *navigationController; } @property (strong, nonatomic) UIWindow *window; @property (nonatomic, retain) UINavigationController *navigationController; @end 

您发布的代码在我的机器上完全编译,因此Xcode项目中的版本很可能包含一个杂散的非打印字符,可能在您声明window属性的行上。 作为一个快速实验,尝试评论该行,看看问题是否存在。

一旦您隔离了包含有问题字符的行,请将其注释掉并在新行上重新键入文本。 一旦你有了工作,你可以删除注释的代码。