service-locator
Description
service-locator
is a framework written in Objective-C that implements a design pattern used in software development to encapsulate the processes involved in obtaining a service with a strong abstraction layer.
Usage
- Define a protocol:
@protocol MyProtocol
@end
- Define a class that conforms to this protocol:
@interface MyClass: NSObject <MyProtocol>
@end
- Register an object in a registry:
#import <ServiceLocator/ServiceLocator.h>
[[NVRegistry sharedInstance] register:@protocol(MyProtocol) scope:NVRegistryScopePrototype factory:factory:^id _Nonnull {
return [[MyClass alloc] init];
}];
- Resolve an object based on a protocol:
#import <ServiceLocator/ServiceLocator.h>
MyClass *myClass = [[NVRegistry sharedInstance] resolve:@protocol(MyProtocol)];
Requirements
- iOS 12.0 / macOS 10.14+ / tvOS 12.0 / watchOS 6.0
- Xcode 15.0
Communication
- If you found a bug, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
Contributing
Bootstrapping development environment
make bootstrap
Please feel free to help out with this project! If you see something that could be made better or want a new feature, open up an issue or send a Pull Request!
Author
Nikita Vasilev, [email protected]
License
service-locator is available under the MIT license. See the LICENSE file for more info.