I am declaring an NSMutableArray in my app delegate :
@property (nonatomic, copy) NSMutableArray * passengerLog;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
passengerLog = [[NSMutableArray alloc]init];
Then in a later class I access the array as follows (del is a reference to the app delegate) :
[del.passengerLog addObject:passenger];
The strange thing is that the second time I add an object to this array, this second object is added to the array twice, overwriting the original object that was already in there.
Can anybody help ?
Thanks !
Are you sure it’s being added twice and is replacing the first one? In your implementation of the app delegate you should refer to the property:
This can be causing the odd behaviour.
EDIT:
Please post some more code so we can help you. Is this the only place where you allocate your array? If yes, are sure that you’re using the same instance of your array all the time?