在目标 C 中使用 sizeof 等价物 [英] using sizeof equivalent in objective C
本文介绍了在目标 C 中使用 sizeof 等价物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何找到结构的大小.在目标 C 中使用 sizeof() 不起作用.
How to find the size of a structure.The use of sizeof() doesnt work in objective C.
推荐答案
sizeof
确实适用于 Objective-C 中的 struct
.例如:
sizeof
does work for struct
in Objective-C. For example:
size_t pointsize = sizeof(NSPoint);
另一方面,如果您对 Objective-C 实例的大小感兴趣,请使用 class_getInstanceSize()
.例如:
On the other hand, if you are interested in the size of Objective-C instances, use class_getInstanceSize()
. For example:
#include <objc/runtime.h>
size_t objsize = class_getInstanceSize([NSObject class]);
这篇关于在目标 C 中使用 sizeof 等价物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文