I would recommend using a singleton instance of your global variable as they have bailed me out of your exact situation multiple times. Here is an example I'm currently using to implement a singleton. This methodology is also ARC-safe as well
mySingleton.h
#import <Foundation/Foundation.h>
@interface mySingleton : NSObject {
}
+ (NSMutableDictionary *) myMutableDict;
@end
mySingleton.m
#import "mySingleton.h"
@implementation mySingleton
+ (NSMutableDictionary *)myMutableDict
{
static NSMutableDictionary *singletonInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
singletonInstance = [[NSMutableDictionary alloc]init];
});
return singletonInstance;
}
@end
As long as you include mySingleton.h in all of your view controllers you can access the data via [mySingleton myMutableDict]
. For example: [[mySingleton myMutableDict] setObject:myObject forKey:myKey];
This will of course work with any object type.