I'm sure I'm missing something stupidly obvious but I'm trying to pass a NSArray to the init method of my class;
And in the class;
Which causes a crash in the program in the for...loop. I know there's something fundamentally wrong but I can't see it and I can't see how to do it differently. Can anyone give me some pointers (sorry, bad pun)?
Code:
NSArray *someStuff[3] = {@"name 1", @"name 2", nil};
MyClass *myInstance = [[MyClass alloc] initWithStuff:*someStuff];
And in the class;
Code:
//Interface
-(id) initWithStuff:(NSArray *)array;
//Method
-(id) initWithStuff:(NSArray *)array
{
NSString *aString;
for (int i =0; i < 3; i++)
{
aString = [array objectAtIndex:i];
// do some stuff with aString
}
return self;
}
Which causes a crash in the program in the for...loop. I know there's something fundamentally wrong but I can't see it and I can't see how to do it differently. Can anyone give me some pointers (sorry, bad pun)?