I have two custom classes: FSGame
and FSEvent
. FSGame
has an ivar that should be an NSMutableArray
of FSEvent
objects.
Here's FSGame.h:
@interface FSGame : NSObject
@property (strong, nonatomic) NSMutableArray *players;
@property (strong, nonatomic) NSString *startTime;
@property (strong, nonatomic) NSString *endTime;
@property (strong, nonatomic) NSMutableArray *gameEvents;
@end
And here's my FSEvent.h:
@interface FSEvent : NSObject
@property NSInteger ID;
@property NSInteger pointTo;
@end
I use
@property (strong, nonatomic) FSGame *game;
to keep an instance of FSGame
in my AppDelegate
. Then, in my application:didFinishLaunchingWithOptions:
I create an instance of FSGame
so it can be filled throughout the "game".
_game = [[FSGame alloc] init];
Then, in one of my view controllers, I alloc
and init
an instance of FSEvent
and then attempt to add it to the .gameEvents
array:
[appDelegate.game.gameEvents addObject: event];
But something seems to go wrong here because if, from another view controller, I try to get access to that object, it will be nil
:
FSEvent *previousEvent = [appDelegate.game.gameEvents lastObject];
if (previousEvent == nil) {
NSLog(@"previousEvent is NIL!");
}
What am I missing here?