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 trialJ.R. Sedivy
2,545 PointsXCode Output
While following along with the instructor and executing the first build I discovered that my output is different than that shown in the video. The video shows "shape area -1.000000" but for my result I received an output on two parts of the bottom portion of my XCode display - on the left there is "L shape - (Shape *) 0x6080000004210" and on the right "(lldb) is displayed.
I double checked that I entered the same code as the video and suspect that perhaps my XCode settings may need to be adjusted. Any suggestions?
2 Answers
Stone Preston
42,016 Pointsyouve got an uncaught exception that is being thrown. so something is wrong with your code. post the code you are using please
J.R. Sedivy
2,545 PointsThanks Stone. Here is the main.m file:
#import <Cocoa/Cocoa.h>
#import "Shape.h"
int main()
{
Shape *shape = [[Shape alloc] init];
NSLog(@"Shape area %f", [shape area]);
return 0;
}
Shape.h file:
#import <Foundation/Foundation.h>
@interface Shape : NSObject
-(float)area;
@end
Shape.m file:
#import "Shape.h"
@implementation Shape
-(float)area {
return -1;
}
@end
Circle.h file:
#import "Shape.h"
@interface Circle : Shape
@property(nonatomic) float radius;
@end
Circle.m file:
#import "Circle.h"
@implementation Circle
-(float)area {
return M_PI * self.radius * self.radius;
}
@end
J.R. Sedivy
2,545 PointsJ.R. Sedivy
2,545 PointsI meant to post the code as a comment to your response, but it looks like I posted it as a top level comment. The code is now here if you wouldn't mind giving it a quick look. Much appreciated!