title: How to initialize different classes of objects automatically?
body: <p>I want to make a class registry class that automatically makes a <code>UITableViewCell</code> and when the user presses the button it'll go to that class and run the code. </p>
  
  <p>Currently to do something like that, in the view controller I have to do something like this</p>
  
  <pre><code>Function1Class *function = [[Function1Class alloc] init];
  function.view.backgroundColor = [self veryLightGrayColor];
  [self.navigationController pushViewController: menu animated: YES];
  </code></pre>
  
  <p>Then in the data source I make a new case in <code>cellForRowAtIndexPath</code>, and in the delegate I make a case in <code>didSelectRowAtIndexPath</code> for a one line method call.</p>
  
  <p>I'd like to change the code so anyone that wants to add a new class to this page can just do it at one place, something like:</p>
  
  <pre><code>Function1 *function;
  [self addClass:function];
  </code></pre>
  
  <p>And in <code>addClass</code> the "function" passed in will be stored in an array</p>
  
  <p>For the <code>cellForRowAtIndexPath</code> and <code>didSelectRowAtIndexPath</code> cases they can easily call the right methods by storing in an array. </p>
  
  <p>The problem is how do I automate the initialization of each class object passed into <code>addClass</code>?</p>
  
  <p>I could get the user to write code like this to add in their class</p>
  
  <pre><code>Function1 *function = [[Function1 alloc] init];
  [self addClass:function];
  </code></pre>
  
  <p>Then the class object is already initialized, but that means during startup EVERY class object is getting initialized, which is a problem if there is a lot of classes. How can I take out a class object from the array, and then initialize it to use it? The class objects are all different classes, so I can't hardcode <code>arrayOfClassObjects[i] = [[Function1 alloc] init];</code></p>
  
  <p>Thanks</p>