Using an object across multiple view controllers
I am trying to create an object that I can use for multiple view controllers by following this thread.
One copy for several species in Cocoa Touch
But it didn't work for me. So I started with the basics to see what was going on. I created a local instance of the object.
PlayerData *playerOne = [[PlayerData alloc] init];
playerOne.completedRound += 1;
I can test this in the debugger and I see 0 for all values ββwhen I create it, and then it is updated with the appropriate line of code, so I feel like my object class is written correctly.
When I try to define an object in my header file like so:
In my UIViewController.h, I added the following
#import "PlayerData.h"
PlayerData *playerOne;
@property (nonatomic, retain) PlayerData *playerOne;
In my UIViewContoller.m I added the following
#import "PlayerData.h"
@synthesize playerOne;
playerOne.completedRound += 1;
I cannot get it to work. The code compiles fine, but views the instance in the debugger with no variable ever getting.
0
a source to share