I have a setter in my class:
-(void)setNumbers:(NSArray *)aNumbers{
NSArray *tArray = [[NSArray alloc]initWithArray:aNumbers]; //throws BAD ACCESS
self.numbers = tArray;
//also tried self.numbers = [tArray copy];
[tArray release];
}
If I invoke the setter like this:
NSArray *numbers = [TicketManager getRandomNumbersFor:@"LottoNormal"];
[self.ticket setNumbers:numbers];
In the 'getRandomNumbersFor:' method (the loop gets executed):
+(NSArray *)getRandomNumbersFor:(NSString *)aTicketType{
NSLog(@"getting RandomNumbers for: %@",aTicketType);
NSMutableArray *tResult;
if([aTicketType isEqualToString:@"LottoNormal"]){
tResult = [NSMutableArray arrayWithCapacity:6];
for(int i = 0;i<6;i++){
int tNumber = arc4random() % 48;
tNumber++;
NSLog(@"Number: %i",tNumber);
[tResult addObject:[NSNumber numberWithInt:tNumber]];
}
}
return tResult;
}
In a ViewController
I´m getting a bad access in the marked line.
Can anyone can help?