Create a class at runtime - Why do NSClassFromString AND objc_getclass return nil? <p>I've tried using both:</p> <pre><code>NSClassFromString and objc_getclass </code></pre> <p>to return a class, so I can create it at runtime, but both functions return nil for some classes, for example "TestClass". Note that NSClassFromString works for me for 99% of classes.</p> <p>If I add </p> <pre><code>[TestClass class]; </code></pre> <p>before I call NSStringFromClass or objc_getclass it, it works. and if I try to just create the class using a class reference, i.e.:</p> <pre><code>[TestClass alloc]; </code></pre> <p>it works too. So how can I force the class to load at runtime so NSClassFromString or objc_getclass will not return nil?</p>