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 trialNick Manring
11,369 Points_profileImage is not taking my code but I'm pretty sure it's right! Xcode says it is! :(
I am using
_profileImage = [UIImage imageNamed:_profileImageName];
after
_profileImageName = [friendsDict objectForKey:@"profilePicture"];
in this exercise and it's not taking. after re-creating this code exercise in Xcode it says it's right. I tried using profileImageName instead of _profileImageName before that, and Xcode changed it to have the underscore which made sense after thinking about. I don't understand. _profileImageName is a NSString, so it is just like the example in the previous video, but that it's not a local variable.... I wish you guys wouldn't switch up things like this and just ask us to re-create the video example but with different names... this is different because you are not asking to create a local variable first. confusing!
thank you!
#import <Foundation/Foundation.h>
@interface Treehouse : NSObject
@property (strong, nonatomic) NSDictionary *friends;
@end
#import "Treehouse.h"
@implementation Treehouse
- (instancetype)init
{
self = [super init];
if (self) {
_friends = @{@"firstName": @"Susan",
@"lastName": @"Olson",
@"profilePicture": @"susan_profile.png"
};
}
return self;
}
@end
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface User : NSObject
@property (nonatomic, strong) NSString *firstName;
@property (nonatomic, strong) NSString *lastName;
@property (nonatomic, strong) NSString *profileImageName;
@property (nonatomic, strong) UIImage *profileImage;
@property (nonatomic, strong) UIImageView *userProfilePhoto;
@end
#import "User.h"
#import "Treehouse.h"
@implementation User
- (instancetype)init
{
self = [super init];
if (self) {
Treehouse *treehouse = [[Treehouse alloc] init];
NSDictionary *friendsDict = treehouse.friends;
_firstName = [friendsDict objectForKey:@"firstName"];
_lastName = [friendsDict objectForKey:@"lastName"];
//Enter your code below!
_profileImageName = [friendsDict objectForKey:@"profilePicture"];
//Above is correct... what is wrong with below code????
_profileImage = [UIImage imageNamed:_profileImageName];
}
return self;
}
@end
1 Answer
Nick Manring
11,369 PointsSo I refreshed my browser by accident. Afterwards, I retyped the first questions (the line above that assigns the name to _profileImageName and continued to the next (the one I was stuck on) and when I entered this same text above, it worked. Looks like the code challenge has some weird cache thing where you can't answer in different ways more than a couple times without it somehow thinking you are wrong no matter what?
all set! might be worth looking into though :P
thanks!