Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 01-16-2009, 02:51 PM   #12 (permalink)
ipodtouchmaster05
Registered Member
 
Join Date: Sep 2008
Posts: 180
Default

Quote:
Originally Posted by DenVogel View Post
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.m file
Code:
NSArray *myArray;
@property (nonatomic, retain) NSArray *myArray;
Here's all the myArray code in my ViewController.h 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.
dude you ARE declaring that array both in your header and .m! Remove the
NSArray * from that statement in your .m, so your .m should look like this:

Code:
@synthesize myArray;
- (IBAction)hello:(id)sender {
	static int lastChosen=0;
	
        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;
}
ipodtouchmaster05 is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,728
Threads: 89,186
Posts: 380,518
Top Poster: BrianSlick (7,127)
Welcome to our newest member, Raggou
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:36 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.