In Objective-C, you can change the dynamic type of an object at run time by assigning it a member variable isa:
id object = ...;
object->isa = [SomeClass class];
Is this behavior undefined? I am currently doing this as a kludge for something else, and it seems to work, but I feel so dirty doing it like that. The new class that I am installing does not add any member variables, it just overrides one method and adds a new one, so the size of the class is the same. I feel that if I resized the object, I would get a lot of bad things.
source
share