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, 01:39 PM   #10 (permalink)
DenVog
Registered Member
 
DenVog's Avatar
 
Join Date: Jan 2009
Location: Silicon Valley, USA
Posts: 622
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 03:08 PM. Reason: reversed .m and .h labels in original post
DenVog is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,726
Threads: 89,185
Posts: 380,515
Top Poster: BrianSlick (7,126)
Welcome to our newest member, donbran2
Powered by vBadvanced CMPS v3.1.0

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