Working with multiple classes files in Objective C -
i have class called graphicobject looks this:
#import <foundation/foundation.h> @interface graphicobject : nsobject { int fillcolor; int linecolor; bool filled; } -(void) fillcolor: (int) fc; -(void) linecolor: (int) lc; -(int) getfilledcolor; -(int) getlinecolor; -(bool) filled: (int) isfilled; @end
and created 3 other files of rectangle
, circle
, triangle
(each of course of study have .h/.m).
for them have access exact same methods, plenty #import
graphicobject.h
?
this graphicobject.m :
#import "graphicobject.h" #import "rectangle.h" //--------------------------get , set filled/line colors----------------------------------// -(void) fillcolor:(int)fc { fillcolor = fc; } -(void) linecolor:(int)lc { linecolor = lc; } -(int) getfilledcolor { homecoming fillcolor; } -(int) getlinecolor { homecoming linecolor; } //-------------------------------------is filled?--------------------------------------------// -(bool) filled:(int)isfilled { isfilled = fillcolor; homecoming isfilled; }
i tried main :
rectangle *myr = [[rectangle alloc] init]; [myr fillcolor:1]; nslog(@"%i", myr.getfilledcolor);
and im getting error...appreciate help.
objective-c
No comments:
Post a Comment