This is really twisting my mind… I'm trying to access an NSMutableArray in an IBAction which I defined in viewDidLoad. Unfortunately I keep getting a EXC_BAD_ACCESS.
I'm new to all this so I'd really appreciate some insight in what I'm doing wrong.
Below find the corresponding code excerpts.
CounterViewController.h:
@interface CounterViewController : UIViewController{
 NSMutableArray *countHistoryArray;
}
@property(nonatomic, retain) NSMutableArray *countHistoryArray;
CounterViewController.m:
@implementation CounterViewController
@synthesize countHistoryArray;
- (void)viewDidLoad {
    [super viewDidLoad];
 //Fill array with some dummy data
 self.countHistoryArray = [[NSMutableArray alloc] init];
 NSDate *now = [[[NSDate alloc] init] autorelease];
 CurrentCount *historicCount = [[[CurrentCount alloc]
         initWithCount:[NSNumber numberWithInteger:22]
         description:@"Testcount"
         dateAndTime:now] autorelease];
 [self.countHistoryArray addObject: historicCount];
 //Do some logging - everything is working fine here!
 NSLog(@"%@", [self.countHistoryArray description]); 
}
//Later on we click on a button and want to use the array
- (IBAction)doSomeStuff {  
    //Let's look at the array again - and now it crashes with EXC_BAD_ACCESS
 NSLog(@"%@", [self.countHistoryArray description]);
}
Thanks a lot!
Manuel
EDIT Additional code as asked for by @jamapag
CurrentCount.h
#import <Foundation/Foundation.h>
@interface CurrentCount : NSObject {
    NSNumber *counterLevel;
    NSString *description;
    NSDate *dateAndTime;
}
- (id)initWithCount:(NSNumber *)newCounterLevel description:(NSString *)newDescription dateAndTime:(NSDate *)newDateAndTime;
@property(nonatomic, copy) NSNumber *counterLevel;
@property(nonatomic, copy) NSString *description;
@property(nonatomic, copy) NSDate *dateAndTime;
@end
CurrentCount.m
#import "CurrentCount.h"
@implementation CurrentCount
@synthesize counterLevel;
@synthesize description;
@synthesize dateAndTime;
- (id)initWithCount:(NSNumber *)newCounterLevel description:(NSString *)newDescription dateAndTime:(NSDate *)newDateAndTime{
    self = [super init];
    if(nil != self){
        self.counterLevel = newCounterLevel;
        self.description  = newDescription;
        self.dateAndTime  = newDateAndTime;
    }
    return self;
}
-(void) dealloc{
    self.counterLevel = nil;
    self.description  = nil;
    self.dateAndTime  = nil;
    [super dealloc];
}
@end
 
     
     
     
     
    