Is it possible to change an Objective-C object to a different type at runtime? -


i have situation want create object before know type be. know superclass be, , want temporarily create concrete instance of superclass , allow other objects use in form until "true" class can created.

i realize pretty crazy , don't have high expectations possible, if amazing. know obj-c runtime has pretty powerful features thought @ least worth asking.

i've looked object_setclass, while appears allow technically change class of object @ runtime, doesn't allow reallocate new instance, complete own ivars, @ address of original instance, need don't know final class (it needs work custom subclass).

background: intention provide placeholder object allow external code register dependencies and/or hold reference to, such when object filled-in, external dependencies still hold , won't have correct references.

you try using nsproxy , proxying "real" underlying object need.