I working on a project in Obj-C where i have a base class (ViewController) and a Derived Class (MultiPlayer).
Now i have declared certain variables and properties in the base class.
My properties are getting accessed from the derived class but im not able to access the variables (int,char and bool type).
I'm completely new to Obj-C so i have no clue whats wrong.
I have used the data types which are used in C and C++.
Is there some specific way to declare variables in Obj-C??
If so, How?
Here are my files
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak,nonatomic) IBOutlet UIImageView* backGroungImage;
@property (strong,nonatomic) IBOutlet UIImageView *blockView1;
@property (strong,nonatomic) IBOutlet UIImageView *blockView2;
@property (strong,nonatomic) IBOutlet UIImageView *blockView3;
@property (strong,nonatomic) IBOutlet UIImageView *blockView4;
@property (strong,nonatomic) IBOutlet UIImageView *blockView5;
@property (strong,nonatomic) IBOutlet UIImageView *blockView6;
@property (strong,nonatomic) IBOutlet UIImageView *blockView7;
@property (strong,nonatomic) IBOutlet UIImageView *blockView8;
@property (strong,nonatomic) IBOutlet UIImageView *blockView9;
@property (strong,nonatomic) UIImage *x;
@property (strong,nonatomic) UIImage *O;
@property (strong,nonatomic) IBOutlet UIImageView* back1;
@property (strong,nonatomic) IBOutlet UIImageView* back2;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
int chooseTheBackground = 0;
int movesToDecideXorO = 0;
int winningArrayX[3];
int winningArrayO[3];
int blocksTotal[9] = {8,3,4,1,5,9,6,7,2};
int checkIfContentInBlocks[9] = {0,0,0,0,0,0,0,0,0};
char determineContentInBlocks[9] = {' ',' ',' ',' ',' ',' ',' ',' ',' '};
bool player1Win = false;
bool player2Win = false;
bool playerWin = false;
bool computerWin = false;
- (void)viewDidLoad
{
[super viewDidLoad];
if(chooseTheBackground==0)
{
UIImage* backImage = [UIImage imageNamed:@"MainBack1.png"];
_backGroungImage.image=backImage;
}
if(chooseTheBackground==1)
{
UIImage* backImage = [UIImage imageNamed:@"MainBack2.png"];
_backGroungImage.image=backImage;
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
I am not able to use the above declared variables in my derived classes!