“Invalid application of 'sizeof' to interface 'Fraction' in non-fragile ABI” in Objective-C

自古美人都是妖i 提交于 2019-11-28 14:14:17

The object's size could still change because you're using the modern ABI. In older versions of Objective-C, objects were basically structs and that meant it was possible to sizeof() them. This is no longer the case, and it was never a particularly good idea in the first place. I'm not sure what Kochan was trying to teach with it, but FYI this is not necessary to program Objective-C. You should be able to get the old behavior by building as 32-bit on the Mac, but again, that isn't something you'll want to do in real programs.

To follow up on what Chuck said, you should use class_getInstanceSize() at runtime if you really need to know the size of an object.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!