objective c - object_setClass to bigger class -


I am changing the class of some objects by using the object_setclass (id object, class class) I am changing the class to a subclass of the original class. I then set some properties which are defined only on the subclass, and things work fine.

I was a little surprised that this works, because object_setClass , as far as I understand, does not re-specify the object, it is only isa Pointer changes if sub class examples are much higher (i.e., many more earners) compared to the example of the original class, so I do not think how the object can work as expected.

Does this work only because there are so many buffer memory (due to alignment etc) between objects in memory?

Is it strong, or in some circumstances can this accident occur?

This may crash as if it can be seen in the source code of the runtime, it is actually only isa swaps the pointer

If you really want to swap the isa in the isa of a subclass with more code If you want, you should use nonzero with additional bytes

code>.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -