Skip to content

nikita-leonov/NLServiceLocator

Repository files navigation

Service Locator for Objective C

Overview

Implementation of Service Locator design pattern for Objective C.

Usage

Register your service for protocol(s) implicitly or explicitly:

[NLServiceLocator registerService:myService];
[NLServiceLocator registerService:myService forProtocol:@protocol(NLSampleService)];

Retrieve services later when you need them by referencing protocol that it conforms and was used for implicit or explicit registration:

id<NLSampleService> myService = [NLServiceLocator serviceForProtocol:@protocol(NLSampleService)];

Done. Enjoy your nicely developed, loosely coupled architecture with an opportunity to replace service by its alternatives in a runtime. Just use it to make your code more managable, or simplify testing by providing mock services with couple of code lines.

Installation

pod "NLServiceLocator"

License

NLServiceLocator is available under the MIT license. See the LICENSE file for more info.

About

Implementation of Service Locator design pattern for Objective C

Resources

License

Stars

Watchers

Forks

Packages

No packages published