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 Using a Playlist Instance

James Goodin
James Goodin
2,483 Points

Playlist app, images not displaying via code

When we change the Playlist app to display the images, for example the coffee image, via code as opposed to letting Interface Building do it I'm not getting the images showing when the app runs. The correctly colored UIImageView shows but in the master view neither the placeholder nor the actual image display.

I have traced through the code path meaning the image is in place in the library corrected and mapped through kIcon, then the string playlistIcon points to that. Everything lines up but no image shows in the Simulator. I do see them as available in Interface Builder meaning where placeholder is shown all the images are also there as options so Xcode is seeing the cassette correctly.

I have tried giving a literal path in the library for the kIcon:@"/Users/Admin/documents... so forth to coffee.pdf" as opposed to just @"coffee.pdf" but no success.

here is the initial code block for the _library the way pasan has it... thanks for input. Jim

- (instancetype)init {
    self = [super init];
    if (self) {
        _library = @[@{kTitle: @"Rise and Shine",
                       kDescription: @"Get your morning going by singing along to these classic tracks as you hit the shower bright and early!",
                       kIcon: @"coffee.pdf",
                       kLargeIcon: @"coffee_large.pdf",
                       kBackgroundColor: @{@"red": @255.0, @"green": @204.0, @"blue": @51.0, @"alpha": @1.0},
                       kArtists: @[@"American Authors", @"Vacationer", @"Matt and Kim", @"MGMT", @"Echosmith", @"Tokyo Police Club", @"La Femme"]

1 Answer

James Goodin
James Goodin
2,483 Points

[SOLVED] I figured it out, it was basically typeO of course. I had a dictionary reference in the setting instead of the appropriate UIImage/imageNamed. Don't howcome it still compiled but I guess syntax wise it was correct just wrong instruction.