Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

Graves Robber
($1.99)

African Adventure
($0.99)

iTazer
($0.99)

ArtStudio
($3.99)

Pigs Vs Wolves
($1.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: 176
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
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Online Users: 317
16 members and 301 guests
armandjo, damienbern, darth_steff, Eskema, Gismo, hrom, HUngable, ipodishima, LemonMeringue, Leopard, oldmicah, RichardFu, shuvo1879, xot-dog, yahya.sadiiq, yunas
Most users ever online was 779, 05-11-2009 at 10:55 AM.
» Stats
Members: 23,721
Threads: 38,484
Posts: 169,070
Top Poster: smasher (2,541)
Welcome to our newest member, oldmicah
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:23 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.