Quote:
Originally Posted by smasher
"You already have a variable myArray, and you made another variable called myArray? WTF?"
|
I am sorry to keep dragging this thread on, but I'd really like to learn what I'm doing wrong. I am still getting two "warning: local declaration of 'myArray' hides instance variable" errors.
I've tried various ways of renaming or removing statements, but am embarrassed to say I can't figure it out.
Here's all the myArray code in my ViewController.h file
Code:
NSArray *myArray;
@property (nonatomic, retain) NSArray *myArray;
Here's all the myArray code in my ViewController.m file
Code:
@synthesize myArray;
- (IBAction)hello:(id)sender {
static int lastChosen=0;
NSArray *myArray= [NSArray arrayWithObjects:
@"Response 1.",
@"Response 2.", nil];
int length = [myArray count];
int chosen;
{
chosen = (float)random() * length /RAND_MAX;
} while(chosen==lastChosen);
NSString *item = [myArray objectAtIndex: chosen];
helloLabel.text = [NSString stringWithFormat: @"%@", item];
[helloLabel setFont: [UIFont fontWithName:@"Verdana-BoldItalic" size:24]];
lastChosen=chosen;
}
I appreciate the patience, and help. I'm sure it's frustrating getting these newbie questions.