Search code examples
objective-cmacosios6

Making an Array call an object in and index


I am getting error that myArray hides an instances variable. Please explain briefly what the error means and how to fix it. Thanks for you help. I am new at programming with objective-c

- (IBAction)buttonPushed:(id)sender
{
    NSArray *snarkyCommentArray = [[NSArray alloc] initWithObjects: @"Butter",@"Cheese",@"Gravy",@"Your fat",@"smells like roses",nil];


    self.snarkOffLabel.text = [snarkyCommentArray objectAtIndex:(1)];

}
@end

Solution

  • I can say, your ivar and local variable have same name. So you need to change the name of either one. Or use arrow operator to access your ivar.