I need a way to conditionally define the superclass of a class based on a value in NSUserDefaults.

I know one can define different interfaces based on #ifdef directive. I wonder if the same can be achieved with #if directive? If not, is there some other way to achieve my goal?

Thank you!

有帮助吗?

解决方案

You cannot do that with a preprocessor directive, since it would be determined at compile time while NSUserDefaults is something you want to check at runtime.

I think this thread could help you Dynamically change an object's superclass Anyway, are you sure this is the best you can do by design? Why would you change the superclass at runtime based on something in NSUserDefaults?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top