Well, first of all, you have know what you're going to do when running on the earlier OS. Basically, you have to write your code as though you were building against the iOS 3.2 SDK. Only then can you add optional enhancements using the newer features.
Starting with the easiest thing: you don't need a declaration of a class interface in order to declare variables, including instance variables, as pointers to that class. You just need a forward declaration:
@class SomeClass;
SomeClass* foo;
Next, there should be no problem with importing a header which defines your class. That's a compile-time thing, which you seem to think is a problem, but which means it's not affected by the runtime environment. It will compile because you're building against the iOS 5.0 SDK.
The thing you have to be careful of is to not use the class if it's not available. You already know how to check that: test if [SomeClass class]
returns Nil
. If it does, don't instantiate your custom subclass.
Finally, you mention "runtime conditionally inheriting from UIReferenceLibraryViewController in myRefLib". Why do you think you need to do that? If UIReferenceLibraryViewController
is not available, then it doesn't make much sense to want to use myRefLib
which subclasses it. If you have some alternative implementation in mind that doesn't depend on UIReferenceLibraryViewController
, then make a separate class. Then conditionally pick between myRefLib
and this other class depending on availability.