title: Can you accomplish some form of dependency injection in objective-c?
body: <p>Currently I'm hard coding another object directly when needed and I'd like the ability to take this in through the init method (I assume?).  In the code below I create a new HatService in the viewDidLoad method and I'd prefer not to do this this for testability / coupling reasons.</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
      HatService* hatService = [[HatService alloc] init];
      [hatService getHatById:self];
  }
  </code></pre>
  
  <p>First question - How should this be done in objective-c?
  Second question - Should I be worried about this or doing it at all?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Here is what I'm starting with but I never seem to hit the first init method during runtime.  I have both declared in the interface - anything else I missed that would allow me to override this init method and inject the service dependency?</p>
  
  <p>Note - I can hit this manually when I create the object myself but when the appDeleage does the work I don't see it hit this (how does the app delegate create this object without calling my init method?)</p>
  
  <pre><code>-(id)initWithHatService:(HatService *)service
  {
    if (self = [super init])
    {
      [self setService:service];
    }
    return self;
  }
  
  -(id)init
  {
    HatService* hatService = [[HatService alloc] init];
    return [self initWithHatService:hatService];
  }
  </code></pre>