my .h file is as follows
我的.h文件如下
#import <Foundation/Foundation.h>
@interface MyClass : NSObject {
}
- (void) addWidget: (Widget*)aWidget;
@end
For sake of example, Widget is just some simple class that only holds a couple of strings. Apparently, either i'm doing something wrong or am just spoiled by Java / C# because when I try building, the compiler tells me that i can't use an object as a parameter to a method.
例如,Widget只是一些只包含几个字符串的简单类。显然,要么我做错了,要么只是被Java / C#宠坏了,因为当我尝试构建时,编译器告诉我,我不能使用对象作为方法的参数。
Does anyone know what I'm doing wrong? Or do objective-c methods not accept complex types? (say it ain't so!)
有谁知道我做错了什么?或者Objective-c方法不接受复杂类型? (说不是这样!)
[UPDATE] Ok this is odd.. but I just selected "clean" from the Build menu and now the error went away.. ah.. such misdirection on my part.
[更新]好的,这很奇怪..但我刚刚从Build菜单中选择了“clean”,现在错误消失了......啊..我这样的误导。
1 个解决方案
#1
The only thing wrong with that code is that Widget isn't declared anywhere. You should either #import "Widget.h"
or put @class Widget;
before the type is used.
该代码唯一的错误是Widget没有在任何地方声明。您应该#import“Widget.h”或者放置@class Widget;在使用类型之前。
#1
The only thing wrong with that code is that Widget isn't declared anywhere. You should either #import "Widget.h"
or put @class Widget;
before the type is used.
该代码唯一的错误是Widget没有在任何地方声明。您应该#import“Widget.h”或者放置@class Widget;在使用类型之前。