Hey there, i have a problem with a exc bad access. I already turned in NSZombieEnabled, but cannot figure out why this problem will be caused. How the cartInstance Array is defined you can see below in the following function. It's a NSMutableArray with several NSMutableDictionaries The error occurs every time my counter i reaches 13. Then i get a exc bad access and the message as shown in the title. Here is some code:
-(void)addToCart:(NSDictionary *) article{
if(article!=nil){
NSString * amount = @"amount";
NSString * articleId = @"articleId";
NSString * detailKey = @"detailKey";
NSString *curId = [article objectForKey:@"articleId"];
//check if article already in shopping cart
if([cartInstance count]>0)
{
for(int i=0;i<[cartInstance count];i++) {
NSString *tempStr = [[cartInstance objectAtIndex:i] objectForKey:articleId];
if([tempStr isEqual:curId]) {
NSNumber *newAmount = [[cartInstance objectAtIndex:i] objectForKey:amount];
NSLog(@"AddtoCart");
int tempInt = [newAmount intValue]+1;//Here is where the magic happens
newAmount = [NSNumber numberWithInt:tempInt];
[[cartInstance objectAtIndex:i] setObject:newAmount forKey:amount];
[newAmount release];
return;
}
}
}
NSDictionary *details = article;
NSDictionary *shoppingItem = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:1],amount,
curId,articleId,
details,detailKey,
nil];
[shoppingItem retain];
[cartInstance addObject:shoppingItem];
id obj;
NSEnumerator * enumerator = [cartInstance objectEnumerator];
while ((obj = [enumerator nextObject])) NSLog(@"%@", obj);
}
else{
NSLog(@"Error: Could not add article to shoppingcart.");
}
}
Can anyone help me out? Thanks in advance.