Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 01-16-2009, 12:39 PM   #10 (permalink)
DenVog
Registered Member
 
DenVog's Avatar
 
Join Date: Jan 2009
Location: Silicon Valley, USA
Posts: 500
Default

Quote:
Originally Posted by smasher View Post
"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.

Last edited by DenVog; 01-16-2009 at 02:08 PM. Reason: reversed .m and .h labels in original post
DenVog is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,208
Threads: 38,991
Posts: 171,023
Top Poster: smasher (2,569)
Welcome to our newest member, JDBurgie
Powered by vBadvanced CMPS v3.1.0

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