title: Objective-C return instances of different classes at init
body: <p>Is it possible at Objective C at init method to return an instance of different classes?
  I'm having a Class called: MyCustomClass. I also have two other different classes called <code>Class 1</code> and <code>Class2</code>. What I'm trying to implement is: When I call <code>[[MyCustomClass alloc] initWithSomeParameters</code> to create instance of <code>Class1</code> or <code>Class2</code> depending on some condition.</p>
  
  <p><code>MyCustomClass.m</code>:</p>
  
  <pre><code>#import "MyCustomClass.h"
  #import "Class1.h"
  #import "Class2.h"
  
  -(id) initWithSomeParameters: (id) params{
    id myClass;
    if (someCondition){
      myClass = [[Class1 alloc] initWithSomeParameters:(id) params];
      [myClass setSomething:something];
    }else{
      myClass = [[Class2 alloc] initWithSomeParameters:(id) params];
      [myClass setSomething:something];
    }
    return myClass;
  }
  </code></pre>
  
  <p>...and later I call</p>
  
  <pre><code>id myCustomClass = [[MyCustomClass alloc] initWithSomeParameters:(id) params];
  </code></pre>
  
  <p>Is this a wrong approach? If so, what would be the correct one?</p>