2

How to find the size of a structure.The use of sizeof() doesnt work in objective C.

spandana
  • 755
  • 1
  • 13
  • 29
  • `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 Answers1

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]);