简体   繁体   English

为什么我收到此Objective-C错误消息:来自'objc_object *'的无效转换

[英]Why am I getting this Objective-C error message: invalid conversion from 'objc_object*'

This error message had me stumped for a while: 这个错误消息让我感到困惑了一段时间:

invalid conversion from 'objc_object* to 'int' 从'objc_object *到'int'的无效转换

The line in question was something like this: 有问题的一行是这样的:

int iResult = [MyUtils utilsMemberFunc:param1,param2];

It doesn't matter what the "to" type is, what is important is that you recognize that this message, in this context, is reporting that the utilsMemberFunc declaration was not found and due to Objective-C's dynamic binding it is assuming it returns an objc_object* rather than the type that utilsMemberFunc was declared to return. “to”类型是什么并不重要,重要的是您认识到此消息在此上下文中报告未找到utilsMemberFunc声明,并且由于Objective-C的动态绑定,它假设它返回objc_object *而不是声明utilsMemberFunc返回的类型。

So why isn't it finding the declaration? 那为什么不找到声明呢? Because ',' is being used rather than ':' to separate the parameters. 因为','而不是':'来分隔参数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS / Objective-C - struct objc_class *和struct objc_object * - iOS / Objective-C - struct objc_class * and struct objc_object * 目标C; typedef objc_object作为没有指针的id的替代; - Objective-C; typedef objc_object as substitute for id without pointer; 为什么我在objective-c中得到指针转换错误的整数? - Why am I getting an integer to pointer conversion error in objective-c? 错误:请求从'objc_object *'转换为非标量类型'CGSize'。 请帮忙? - Error: Conversion from 'objc_object*' to non-scalar type 'CGSize' requested. Please help? Objective-C:为什么在尝试从nsmutable数组中删除对象时出现异常? - Objective-C: Why I am getting exception trying to remove object from nsmutable array? 为什么在Objective-C中会收到“消息发送到已释放实例的消息”? - Why am I getting “Message sent to deallocated instance” in Objective-C? Objective C iOS - objc_object :: sidetable_retain / release占用循环中的CPU时间? - Objective C iOS - objc_object::sidetable_retain/release chewing up CPU time in my loop? 为什么在Objective-C中向前声明根类时出现错误? - Why I am getting an error while forward declaring root class in Objective-C? Objective-C:为什么在导入头文件时出现编译错误? - Objective-C: Why am I getting a compile error when importing a header file? 无法获得Objective-C对象来响应消息。 我想念什么? - Can't get an objective-c object to respond to a message. What am I missing?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM