When my program gets to the line: [userNumSequence addObject:[NSNumber numberWithInteger: sequenceNumber]]; it gets the error: Program received signal: “EXC_BAD_ACCESS”.
All I'm wanting to do is to store an integer in the array.
// JBNumberGeneration.m
#import "JBNumberGeneration.h"
@implementation JBNumberGeneration
- (id) init{
if (self = [super init]){
userNumSequence = [NSMutableArray arrayWithCapacity:0];
} return self;
}
-(IBAction)logSequenceNumber:(id)sender{
NSString *titleOfButton = [sender title];
int sequenceNumber = [titleOfButton integerValue];
i=0;
[userNumSequence addObject:[NSNumber numberWithInteger: sequenceNumber]];
//int currentNum = [((NSNumber*)[userNumSequence objectAtIndex: i]) integerValue];
//NSLog(@"%i", currentNum);
int count = [userNumSequence count];
NSLog(@"Array size: %i", count);
i++;
}
@end
// JBNumberGeneration.h
#import <Cocoa/Cocoa.h>
@interface JBNumberGeneration : NSObject {
IBOutlet NSTextField *displayLabel;
int randNum;
int level;
int i;
NSMutableArray* userNumSequence;
}
-(IBAction)logSequenceNumber:(id)sender;
@end