I am quite new to Objective-C but have quite a bit of experience in C#. I am trying to check out some dependency injection frameworks in Objective-C. While looking into some frameworks, i found something very different with respect to the constructors/Initializers in an Objective-C class.
If i want to inject an object through a constructor like below,
-(id)initWithService:(id<ServiceProtocol>)service;
of course this won't be the default constructor and the control will not enter here until this is called from some other place.
only -(id)init
is the default constructor and the control goes here when this object is injected.
So i am wondering if its a good practice to call initWithService
from -(id)init
?
Or for every class just have two initializers use the initializer with constructor only during mocking and ignore it during the auto initialization process by the framework ?