I'm learning Objectiv开发者_Go百科e-C, noob question.
I'm working on a project in Xcode that requires multiple geometric object-types (square, triangle, etc). Each object file is made a subclass of the superclass "GraphicObject," for which there is a file as well obviously.
My question is, when I create a new file to contain main code body, I cannot seem to make the new file recognize the subclasses of GraphicObject unless I do this:
#import "GraphicObject.h"
#import "Rectangle.h"
#import "Triangle.h"
#import "Circle.h"
#import "Square.h"
Is there a way for me to have the file refer to all subclasses of the GraphicObject class without explicitly adding them via the #import function?
Thank you for reading.
I think you are confusing subclasses and dependencies. Just because Rectangle
inherits from GraphicObject
, the class that uses just GraphicObject
has no idea what Rectangle
is. You would need to use all of those #imports
.
精彩评论