“无效值不应被忽略”错误
我收到一条错误消息“无效值不应被忽略”:
home = [[Home alloc] initWithPhoto:imageView.image];
请帮忙。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的 Home 类的
-initWithPhoto:
函数可能返回 void。初始化函数应该返回id
。Your Home class'
-initWithPhoto:
function is probably returning void. Initializer functions are supposed to returnid
.initWithPhoto
的返回值是多少?该错误意味着该方法返回void
但您正在将其分配给某些内容。initWithPhoto
应该看起来像这样:该方法应该返回
id
,而不是void
。What is the return value of
initWithPhoto
? The error means that the method is returningvoid
but you are assigning that to something.initWithPhoto
should look something like this:The method should return
id
, notvoid
.您的
initWithPhoto
方法在应该返回id
类型的对象时返回了void
类型的对象,特别是如果您期望 < code>home 变量包含任何有用的内容。尝试编辑initWithPhoto
方法以返回id
类型的对象。Your
initWithPhoto
method is returning an object of typevoid
when it should be returning an object of typeid
, especially if you're expecting thehome
variable to contain anything useful. Try editing theinitWithPhoto
method to return an object of typeid
.