Any help figuring this out would be appreciated. I have 3 NSMutableArrays in a singleton (Game Manager) and only one of them will work when I go to access the data I try to store, even though I use them all the same.
Here is where I initialize them in my GameManager.h
- (GameManager *)init
{
if ((self = [super init]))
{
gameTexts = [[NSMutableArray alloc] init];
gameDrawings = [[NSMutableArray alloc] init];
playerNames = [[NSMutableArray alloc] init];
}
return self;
}
Here is where I go to store values in them. This seems to be where the problem is from NSLogs I put in.
[[GameManager sharedManager].playerNames addObject:[NSString stringWithFormat:@"%@",nextPlayerName.text]];
[[GameManager sharedManager].gameTexts addObject:[NSString stringWithFormat:@"%@",inputText.text]];
[[GameManager sharedManager].gameDrawings addObject:([[GameManager sharedManager] previousDrawing])];
Here is where I try to retrieve the data.
names.text = [[GameManager sharedManager].playerNames objectAtIndex:(nameIndex)];
texts.text = [[GameManager sharedManager].gameTexts objectAtIndex:(textIndex)];
drawings.image = [[GameManager sharedManager].gameDrawings objectAtIndex:(drawingIndex)];
Only the playerNames array will work correctly. The other two give me bad access errors when I try to use the NSLog to see what is in them.
Any ideas are welcome, as I have been stuck on this a while. Thanks
It sounds like
gameTextsandgameDrawingsare getting over-released somewhere. That is almost always the cause ofEXC_BAD_ACCESS.