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 trialjames white
78,399 PointsOut of this world with stars and asteroids..
So just guessing I implemented this code based on the code in the zip file
substituting "asteroid" for "star".
asteroid.h
@interface ColoredCircle : Circle
@property (nonatomic,retain) NSString* color;
-(instancetype) initWithDiameter:(float)d andColor:(NSString*)c;
+(ColoredCircle*) asteroid;
@end
asteroid.m
#import "ColoredCircle.h"
@implementation ColoredCircle
-(instancetype) init {
return [self initWithDiameter:6 andColor:@"blue"]; // default diameter is 6, default color is "blue"
}
-(instancetype) initWithDiameter:(float)d andColor:(NSString *)c {
self = [super initWithDiameter:d];
if (self) {
self.color = c;
}
return self;
}
+(ColoredCircle*) asteroid {
ColoredCircle *s = [[ColoredCircle alloc] initWithDiameter:1.5 andColor:@"grey"];
return s;
}
@end
The code seems to pass as long as you use the correct values for:
initWithDiameter:1.5 andColor:@"grey"
..however I kept getting all kinds of errors regarding missing a pointer to ColoredCircle
before I got to this point.
I guess I missed the whole section of the course which went
into how "alloc" effectively means using pointer(s) (somehow)..?
I don't know -- just very confusing..
Maybe (hopefully) I got most of this right (at least):
https://teamtreehouse.com/community/summary-clarification-for-class-factory-methods-in-ios