Reputation: 3
I am working on a game. The game has different levels but share the same methods. I was thinking about subclassing the main game class.
How can i subclass the main game class(the main game class is a subclass of viewcontroller with xib)? Can i overrider the xib with subclass's xib?
//my main game class.
@interface Game : UIViewController{
//subclass
import <UIKit/UIKit.h>
import "Game.h"
@interface level1 : Game {
}
when i used level1.view, it gave me an error"accessing unknown view class method)
It it is impossible, how can i create a game with different levels~~ thanks
Upvotes: 0
Views: 324
Reputation: 42588
accessing unknown view class method
This looks like you are calling [level1 view]
. This is an attempt to call a class method name +view
. There is no such class method. You are attempting to get to an instance method name -view
.
level1 *myLevel1 = [[level1 alloc] initWithNibName:nibName bundle:nibBundle];
myLevel1.view;
BTW: It is the usual practice to have a capital letter begin a class. So the class name should be Level1
not level1
.
Upvotes: 1
Reputation: 3454
One approach is to create layers on your view for each level.
Upvotes: 0