How do I refer to a view controller in a subclass?
- by thekevinscott
Hey all, I'm currently teaching myself Objective C and I'm kind of stuck.
I'm building a backgammon game and I have a subclass, "Piece", which is being initialized, repeatedly, in BackGammonViewController.
In BackGammonViewController, if I do this:
UIImage *myImage = [ UIImage imageNamed: @"white-piece.png" ];
UIImageView *myImageView = [ [ UIImageView alloc ] initWithImage: myImage ];
[self.view addSubview:myImageView];
[myImageView release];
The image appears. However, I want to do this within my "piece" class. How do I refer to the "self.view" from within the piece class? Do I need to pass a reference to the view, into the "piece class" ? Or is there a global reference I can call from within the "piece class" ?
Thanks for your help.