Mashhadi
Mashhadi

Reputation: 3024

"void value not ignored as it ought to be" error

I am getting an error "void value not ignored as it ought to be" on the line:

home = [[Home alloc] initWithPhoto:imageView.image];

Please help.

Upvotes: 2

Views: 1547

Answers (3)

taskinoor
taskinoor

Reputation: 46027

What is the return value of initWithPhoto? The error means that the method is returning void but you are assigning that to something. initWithPhoto should look something like this:

- (id)initWithPhoto:(UIImage *)image {
    if (self = [super init]) {
         // do your tasks
    }

    return self;
}

The method should return id, not void.

Upvotes: 2

Scott Forbes
Scott Forbes

Reputation: 7417

Your initWithPhoto method is returning an object of type void when it should be returning an object of type id, especially if you're expecting the home variable to contain anything useful. Try editing the initWithPhoto method to return an object of type id.

Upvotes: 1

Nate Thorn
Nate Thorn

Reputation: 2183

Your Home class' -initWithPhoto: function is probably returning void. Initializer functions are supposed to return id.

Upvotes: 4

Related Questions