什么是“意外的接口名称”?在 Objective C 中,iPhone 的开发?
我使用的是 MapMultiController 类,它扩展了 UIViewController,并从 ListViewController 内部实例化,ListViewController 也扩展了 UIViewController,如下所示:
@interface MapMultiController : UIViewController <UINavigationControllerDelegate, UINavigationBarDelegate> {
MKMapView *mapView;
UISegmentedControl *barStyleSegControl;
bool wasUpdated;
}
然后是这样的:
MapMultiController *controller = [[MapMultiController alloc] initWithNibName:@"MapMultiController" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[controller release];
这一切之前都有效,但后来我注释掉了分配以及 ListViewController 中的所有内容,并做了一些其他事情,现在当我尝试将其放回去时,它显示“意外的接口名称'MapMultiController'”,当然之后的一切都不起作用。
但对我来说一切看起来都是正确的!怎么了?
I was using a class, MapMultiController, which extends UIViewController, and is instantiated from inside my ListViewController, which also extends UIViewController, like so:
@interface MapMultiController : UIViewController <UINavigationControllerDelegate, UINavigationBarDelegate> {
MKMapView *mapView;
UISegmentedControl *barStyleSegControl;
bool wasUpdated;
}
and then this:
MapMultiController *controller = [[MapMultiController alloc] initWithNibName:@"MapMultiController" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[controller release];
This all worked before, but then I commented out the allocation and all that from my ListViewController, and did some other things, and now when I'm trying to put it back in, it says "Unexpected interface name 'MapMultiController'", and of course everything after that doesn't work.
But everything looks correct to me! What's wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可能发生的情况是,在编辑过程中,您在 @interface 之前添加了一些代码,而现在编译器并不期望它出现在它找到它的地方。不是你的代码错了,而是你的代码放错了地方。
What probably happened is that in the course of your editing, you added some code before that @interface and now the compiler isn't expecting it where it's finding it. It's not that your code is wrong, but that it's in the wrong place.
当您创建一个不允许创建对象的对象时,通常会发生此错误。
当我在
switch
语句中分配对象时,也发生了同样的错误:产生以下错误:
This error usually happens when you create an object where object creation is simply not allowed.
This very same error happened to me when I was allocating an object inside a
switch
statement:Yields following error:
Shaharyar 并不完全正确,您可以从 switch 语句中分配和创建对象,只要您用大括号将每个情况括起来。
以下是 switch 语句的有效用法:
Shaharyar isn't strictly correct, you can alloc and create objects from within a switch statement as-long as you enclose each case with curly brackets.
The following is valid use of the switch statement: