Hi, I don't understand why I can't access self.cardButtons in the child class SetCardCardgameViewController. The parent is CardgameViewController.
CardgameViewController.h:
CardgameViewController.m
SetCardCardgameViewController.h
SetCardCardgameViewController.m
this last self.cardButtons isn't recognized. But cardButtons is a property of the parent class. Why isn't it recognized? I agree it's privately declared but as SetCardCardgameViewController is a child of CardgameViewController, I thought I could access all its properties and methods. Or am I mistaken?
CardgameViewController.h:
Code:
#import <UIKit/UIKit.h>
#import "Deck.h"
@interface CardgameViewController : UIViewController
- (void) updateUI;
// protected
// for subclasses
- (Deck *)createDeck;
// must be overriden in SetCardGameViewController as contents is not to be used for instance
- (NSAttributedString *)titleForCard: (Card *)card;
- (UIImage *)backgroundImageforCard: (Card *)card;
@end
CardgameViewController.m
Code:
#import "CardgameViewController.h"
//#import "PlayingCardDeck.h"
#import "CardMatchingGame.h"
@interface CardgameViewController ()
@property (strong, nonatomic) CardMatchingGame *game;
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *cardButtons;
@property (weak, nonatomic) IBOutlet UILabel *scoreLabel;
@property (weak, nonatomic) IBOutlet UISegmentedControl *matchMode;
@property (weak, nonatomic) IBOutlet UILabel *status;
@property (weak, nonatomic) IBOutlet UISlider *historySlider;
@property (weak, nonatomic) IBOutlet UILabel *historyOverview;
@end
SetCardCardgameViewController.h
Code:
#import "CardgameViewController.h"
@interface SetCardCardgameViewController : CardgameViewController
@end
SetCardCardgameViewController.m
Code:
#import "SetCardCardgameViewController.h"
#import "SetCardDeck.h"
#import "SetCard.h"
@interface SetCardCardgameViewController ()
@end
@implementation SetCardCardgameViewController
- (void)updateUI
{
for (UIButton *cardButton in self.cardButtons) {
}
}
this last self.cardButtons isn't recognized. But cardButtons is a property of the parent class. Why isn't it recognized? I agree it's privately declared but as SetCardCardgameViewController is a child of CardgameViewController, I thought I could access all its properties and methods. Or am I mistaken?
Last edited: