2012-06-26 72 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: 

但實際上它是你的電話......