我对objective-c很陌生,我自己尝试了一些例子。这是我的示例代码
#import <objc/objc.h>
#import <Foundation/Foundation.h>
@interface Test:NSObject
{
int noOfWheels;
int total;
}
@property int noOfWheels;
@property int total;
-(void) print;
@end
@implementation Test
@synthesize noOfWheels, total;
-(void) print
{
NSLog (@" noofWheels is %i, total %i ", noOfWheels, total);
}
@end
int main ( int argc, char ** argv)
{
Test *t = [Test alloc];
t = [t init];
[t setnoOfWheels: 10];
[t settotal: 300];
[t print];
}
并且它编译没有错误,但是当我运行程序时出现以下错误。
Uncaught exception NSInvalidArgumentException, reason: -[Test setnoOfWheels:]: unrecognized selector sent to instance 0x87aef48
我在我的代码中做错了什么?