Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
leo kamin
5,550 PointsLocal declaration of of 'add' hides instance variable?
I get this warning with my code and here it is the pos variable is declared in the .h file
float add = 20;
NSLog(@"%f",pos);
pos = add + pos + 35;
NSLog(@"%f",pos);
2 Answers
Mike Baxter
4,442 PointsIf "add" is declared in your header (.h) file, then you don't need to qualify it with "float" in your implementation file. (And you shouldn't, that's why you'll get that error.)
Instead, as long as you have in your header file,
float add;
then you only have to make your code say:
add = 20;
NSLog(@"%f",pos);
pos = add + pos + 35;
NSLog(@"%f",pos);
leo kamin
5,550 Pointsthank you