title: Objective-C - Factory to return a given class type?
body: <p>With generics on languages like C# or Java, you can have a factory that returns a result depending on the given type? For example you can tell the factory method to return:</p>
  
  <pre><code>Book
  List&lt;Book&gt;
  Door
  List&lt;Door&gt;
  </code></pre>
  
  <p>Is it possible to achieve the same thing with objective-c?
  Can I somehow tell <code>generateObjects</code> method to return me an array of books?</p>
  
  <pre><code>[self getDataFromWeb:@"SOME_URL" andReturnResultWithType:[Book class]];
  // What about an array of Books?
  
  - (id)getDataFromWeb:(NSString*)url andReturnResultWithType:(Class)class
  {
      // Convert JSON and return result
      // Mapping conversion is a class method under each contract (Book, Door, etc)
  } 
  </code></pre>
  
  <p>Let's say this is one of my data contracts</p>
  
  <pre><code>@interface Book : JSONContract
  
  @end
  
  @implementation Book
  
  + (NSDictionary *)dataMapping
  {
     // returns an NSDictionary with key values
     // key values define how JSON is converted to Objects
  }
  
  @end
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Modified the examples to be more clear</p>