So, I was watching Stanford iPhone App developing course online, and I got stuck at one of the assignments they gave out.
One of the specifications for the assignment is following:
Give your view class access to the PolygonShape object so that it can
retrieve the details of the polygon as needed
Part of my header for the controller class is this:
@interface Controller : NSObject {
IBOutlet PolygonView *myView;
IBOutlet PolygonShape * polygon;
}
Here, a PolygonShape object 'polygon' and a PolygonView object 'myView', which is a subclass of UIView are declared in the Controller object.
Currently 'polygon' is connected with a PolygonShape object created in the Interface Builder, and 'myView' is connected as an outlet to the PolygonView in the Interface Builder as well.
Since I was asked to have the same 'polygon' object living inside the View object, I did something like this:
@interface PolygonView : UIView {
IBOutlet PolygonShape * polygon;
}
and connected as an outlet to the same PolygonShape object from Interface Builder.
My question is, is there a better way to connect the 'polygon' object of Controller class and 'polygon' of PolygonView class other than drag-and-drop in the Interface Builder?
What I tried to do was that inside the AwakeFromNib method of Controller Class, I assigned 'polygon' to the myView's 'polygon' as:
myView.polygon=polygon;
although it threw an error saying "Object cannot be set". What I had in mind was since both polygons are pointers to the PolygonShape object, I thought I should be able to assign one into another to make both of them to point at the same thing. I know there is something wrong with my argument but don't know exactly what.
Thank you all for your help.
One of the specifications for the assignment is following:
Give your view class access to the PolygonShape object so that it can
retrieve the details of the polygon as needed
Part of my header for the controller class is this:
@interface Controller : NSObject {
IBOutlet PolygonView *myView;
IBOutlet PolygonShape * polygon;
}
Here, a PolygonShape object 'polygon' and a PolygonView object 'myView', which is a subclass of UIView are declared in the Controller object.
Currently 'polygon' is connected with a PolygonShape object created in the Interface Builder, and 'myView' is connected as an outlet to the PolygonView in the Interface Builder as well.
Since I was asked to have the same 'polygon' object living inside the View object, I did something like this:
@interface PolygonView : UIView {
IBOutlet PolygonShape * polygon;
}
and connected as an outlet to the same PolygonShape object from Interface Builder.
My question is, is there a better way to connect the 'polygon' object of Controller class and 'polygon' of PolygonView class other than drag-and-drop in the Interface Builder?
What I tried to do was that inside the AwakeFromNib method of Controller Class, I assigned 'polygon' to the myView's 'polygon' as:
myView.polygon=polygon;
although it threw an error saying "Object cannot be set". What I had in mind was since both polygons are pointers to the PolygonShape object, I thought I should be able to assign one into another to make both of them to point at the same thing. I know there is something wrong with my argument but don't know exactly what.
Thank you all for your help.