How to find the size of a structure.The use of sizeof() doesnt work in objective C.
Asked
Active
Viewed 2,249 times
2
-
`sizeof` does work for `struct`. Are you interested in the size of a class/instance? – May 05 '11 at 10:10
-
have you checked http://stackoverflow.com/questions/761969/checking-the-size-of-an-object-in-objective-c – perreal May 05 '11 at 10:11
1 Answers
7
sizeof
does work for struct
in Objective-C. For example:
size_t pointsize = sizeof(NSPoint);
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]);