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 trialJonathan Fernandez
8,325 PointsDid I miss something with Syntax?
So basically I have been trying to keep up with the video's syntax for creating button shapes, although Xcode will not allow me to create them cause it says "circle" is an undeclared variable. Although I have exactly all the syntax exactly as the video in "main.m".
So since the syntax is the same, the only conclusion I can come to think of is that the instructor may have changed a bit of the syntax of circle classes from the previous video called Inheritance. Since in this video he had also added a new class for rectangles.
Shown bellow is my code in main.m (I can't compare Circle.h cause he doesn't show it in the Composition video):
#import <Cocoa/Cocoa.h>
#import "Shape.h"
#import "Circle.h"
#import "Button.h"
int main()
{
Shape *shape = [[Shape alloc]init];
NSLog(@"shape area %f",[shape area]);
Circle *round = [[Circle alloc]init];
NSLog(@"cicle area %f",[round area]);
Button *roundButton = [[Button alloc]init];
roundButton.shape = circle;
return 0;
}
Am I just missing something obvious cause I'm cramming too many hours and am missing something obvious? or is there really a difference of class codes within the two videos. Any feedback will be greatly appreciated! : )
1 Answer
Jonathan Fernandez
8,325 PointsUpdate
Never-mind.. I'm the fool.. I just went through syntax and realized "round" does not = to "circle".. ><
Bellow is the new code that doesn't show any syntax errors to undeclared identifiers:
#import <Cocoa/Cocoa.h>
#import "Shape.h"
#import "Circle.h"
#import "Button.h"
int main()
{
Shape *shape = [[Shape alloc]init];
NSLog(@"shape area %f",[shape area]);
Circle *circle = [[Circle alloc]init];
NSLog(@"cicle area %f",[circle area]);
Button *roundButton = [[Button alloc]init];
roundButton.shape = circle;
return 0;
}