deck
is my superclass and playingCardDeck
is my subclass of deck.
i found that i can i instantiation my superclass by using my subclass which confuse me a lot.
Can you tell me about this.Which init
method will be used and any other features about this.thanks in advance.
#import "XYZViewController.h"
#import "PlayingCardDeck.h"
@interface XYZViewController ()
@property (weak, nonatomic) IBOutlet UILabel *flipLabel;
@property (nonatomic) NSUInteger flipCount;
@property (nonatomic) Deck *deck;
@end
@implementation XYZViewController
- (Deck *)deck
{
if (!_deck) {
_deck=[self createDeck];
}
return _deck;
}
- (Deck *)createDeck
{
return [[PlayingCardDeck alloc]init];
}