8

I am trying to dynamic create objc class at runtime and I need to add some Ivar to the created class. I found class_addIvar which should do what I want, but I also found these functions:

  • class_setIvarLayout
  • class_getIvarLayout
  • class_getWeakIvarLayout
  • class_setWeakIvarLayout

the doc did not really said any useful information about these methods and I can't find out any useful explanation from web. So what are they? Do I need to use them if I want to do something with Ivar?

1 Answer 1

9

The class_*IvarLayout methods are used by the garbage collector (if/when you're using it) to determine which areas of an object's memory need to be scanned for strong/weak references.

It's unlikely you'll ever need to call these methods; the appropriate layouts are generated when you call objc_registerClassPair.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.