Reputation: 3024
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
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
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
Reputation: 2183
Your Home class' -initWithPhoto:
function is probably returning void. Initializer functions are supposed to return id
.
Upvotes: 4