视图控制器上的inheritance目标c

我正在尝试创建一个通用的视图控制器和其他两个将inheritance的视图。

现在这是通用视图(我认为是相关的 – 如果需要其他东西我将添加它):

@interface CardGameViewController () @property (strong, nonatomic) IBOutlet UITabBarItem *TabSelection; @property (strong, nonatomic) CardMatchingGame *game; @property (strong, nonatomic) IBOutlet UIButton *resetButton; @property (weak, nonatomic) IBOutlet UILabel *scoreLable; @property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *cardButtons; @end @implementation CardGameViewController - (CardMatchingGame*)game { if(!_game) _game = [[CardMatchingGame alloc]initWithCardCount:[self.cardButtons count] usingDeck:[self createDeck] gameMode:[self getActiveTabWithString:self.TabSelection.description]]; return _game; } - (Deck*)createDeck //abstract { return nil; <------- Relevant generic function } 

这些是inheritance上述文件的2个文件:

SetGameViewController.h:

 #import "CardGameViewController.h" @interface SetGameViewController : CardGameViewController @end 

SetGameViewController.m:

 #import "SetGameViewController.h" #import "SetCardDeck.h" @interface SetGameViewController () @end @implementation SetGameViewController -(Deck*)createDeck { return [[SetCardDeck alloc]init]; } @end 

第二个:

PlayingCardGameViewController.h:

 #import "CardGameViewController.h" @interface PlayingCardGameViewController : CardGameViewController @end 

PlayingCardGameViewController.m:

 #import "PlayingCardGameViewController.h" #import "PlayingCardDeck.h" @interface PlayingCardGameViewController () @end @implementation PlayingCardGameViewController - (Deck*)createDeck { return [[PlayingCardDeck alloc]init]; } @end 

我还有标签栏导航器在2个视图之间切换。

问题是,无论我做什么,第一个(SetGameViewController)都不会被实例化,

这意味着永远不会调用createDeck函数,

而第二个(PlayingCardGameViewController)每次都可以。

我尝试过的:

在主视图上放置断点- (CardMatchingGame*)gamefunction。

当我试图开始第二个工作视图而不是坏视图时,这个只被调用。

如果有什么遗漏可以提供一定的线索,请告诉我,我会添加它。

在基类中的空createDeck方法以及两个子类中的方法上设置断点。

我的猜测是,当您在IB(Interface Builder)中设置标签栏控制器时,您将其中一个标签设置为通用CardGameViewController的实例,而不是SetGameViewController。