2012-06-26 71 views
0

我收到此错误 “没有setter方法‘setOrgin:’对于转让财产”目标C问题

Rectangle *r =[[Rectangle alloc]init]; 
XYpoint *p =[[XYpoint alloc]init]; 
[p setXY : 100 : 300]; 
[r setWH: 6 : 8]; 
r.orgin =p; 
NSLog(@"Width and height is %i and %i", r.width, r.height); 
NSLog(@"Origin is at %i and %i", r.orgin.x, r.orgin.y); 
NSLog(@"Area and Peri are %i and %i", [r area], [r perimeter]); 

请帮我这个

回答

0

这可能是一个错字。你有'orgin'而不是'origin'[缺少'i'](我相信这是你的Rectangle课程中的一个属性)。 还要注意像setXY::(虽然它们是有效的)在Objective-C世界中被认为是不好的编程风格。这种方法签名更常见的模式是:

setX:andY: 

但实际上它是你的电话......