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

use of undeclared identifier 'didreceivememorywarning'

I'm getting the above message on my build a playlist Browser with Objective - C but I have no idea how to fix it.

#import "PlaylistMasterViewController.h"
#import "PlaylistDetailViewController.h"
#import "Playlist.h"

@interface PlaylistMasterViewController ()
@end
@implementation PlaylistMasterViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    for (NSUInteger index = 0; index < self.playlistImageViews.count; index++) {

        Playlist *playlist = [[Playlist alloc] initWithIndex: index];

        UIImageView *playlistImageView = self.playlistImageViews[index];

        playlistImageView.image = playlist.playlistIcon;
        playlistImageView.backgroundColor = playlist.backgroundColor;
}

1 Answer

Michael Hulet
Michael Hulet
47,912 Points

Somewhere in your project (though I don't see it in this snippet), you tried to call the method "didreceivememorywarning" without defining it. My bet is that you were trying to define the "didReceiveMemoryWarning" method somewhere, and did something like this:

-(void)didreceivememorywarning{
    //This line would cause a problem
    [super didreceivememorywarning];

    //You might have other code down here
}

This would be a version of that method that wouldn't cause a problem:

//Notice the capitalization
-(void)didReceiveMemoryWarning{
    //This wouldn't cause a problem
    [super didReceiveMemoryWarning];

    //You can put other code down here, too
}