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

iOS Build a Playlist Browser with Objective-C Managing Playlist Data Creating UIImageViews

'UIKit/UIKit.h' file not found #import ^ 1 error generated. Getting this error how do finish answering

getting that error how do i finish answering the question

Treehouse.h
#import <Foundation/Foundation.h>

@interface Treehouse : NSObject

@property (strong, nonatomic) NSDictionary *friends;

@end
Treehouse.m
#import "Treehouse.h"

@implementation Treehouse

- (instancetype)init
{
    self = [super init];
    if (self) {
        _friends = @{@"firstName": @"Susan",
                     @"lastName": @"Olson",
                     @"profilePicture": @"susan_profile.png"
                     };
    }
    return self;
}



@end
User.h
#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
User.m
#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"];
    }
    return self;
}

@end
Christopher Augg
Christopher Augg
21,223 Points

Please remove the line:

#import <UIKit/UIKit.h>

from User.h and it should pass

Regards,

Chris

3 Answers

Christopher Augg
Christopher Augg
21,223 Points

Bharath,

My apologies for the inconvenience with this issue. Yes, I have tested it through all 3 tasks and it works if you remove the #import UIKit/UIKit.h line from User.h

Here is the code I used for all 3 tasks to pass without the import:

User.m
#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"];


        //Task 1

      _profileImageName = [friendsDict objectForKey:@"profilePicture"];

        //Task 2

      _profileImage = [UIImage imageNamed:_profileImageName];

        //Task 3

      _userProfilePhoto = [[UIImageView alloc] initWithImage:_profileImage];
    }
    return self;
}

@end

I still have this being looked at and hope this will get you back on track in the meantime.

Please let me know if I can be of any further assistance.

Regards,

Chris

sorry should have tried. will do that thanks Chris

Christopher Augg
Christopher Augg
21,223 Points

Bharath,

It looks like you have found a bug. Your code looks correct to me. I have submitted this to support as it keeps giving the error as you said:

'UIKit/UIKit.h' file not found #import ^ 1 error generated..

Regards,

Chris

Thank you! it also stops me from going to the next question may be you guys can allow that, thanks anyway

hmmm..... will it work? we have members dependent on UIKit like UIImage.