Comments (2)
This is a hack fix, but it worked for me. I'm explicitly passing in Void into the initializer.
The Void being in a tuple is to remove the Swift warning: 'When calling this function in Swift 4 or later, you must pass a '()' tuple; did you mean for the input type to be '()'?'. This is normally a good warning. However, to make the overloaded function work correctly, I needed to explicitly pass in Void.
@discardableResult
public func autoregister<Service>(_ service: Service.Type, name: String? = nil, initializer: @escaping ((Void)) -> Service) -> ServiceEntry<Service> {
return self.register(service.self, name: name, factory: { res in
initializer(Void())
} as (Resolver) -> Service)
}
from swinjectautoregistration.
After forking the repo to fix the issue, I noticed that the issue has already been fixed, and I was using 2.1.0. Sorry about all the commotion for an issue that's already been fixed.
I've made a pull request that adds a test for auto resolving a type that has an initializer with zero parameters. Feel free to merge it or reject it if you don't think it's necessary.
from swinjectautoregistration.
Related Issues (20)
- Framework size HOT 1
- Xcode 10.2 Support HOT 2
- Release Swift5 version HOT 1
- Possible Limitation of SwinjectAutoregistration Involving Initializers HOT 2
- Mix dependencies with and without arguments HOT 1
- More auto extensions HOT 3
- Autoregistration for property injection HOT 9
- Auto-register on resolve HOT 1
- SwinjectAutoregistration crashes on Xcode 12.0 (12A7209) HOT 5
- Swinject crash on iOS 14 HOT 4
- Showing Ambiguous use of 'init' when opening the project on Xcode version 12.0 + HOT 3
- Reason for container.autoregister with max of 3 arguments only HOT 1
- arm64 is missing from ARCHS HOT 4
- How to auto register when init has default arguments? HOT 1
- Allow dynamic in Package.swift HOT 2
- Support for Xcode13 HOT 5
- Wrong version of Swinject on podspec HOT 7
- Build fails on Carthage without xcframeworks HOT 1
- the path does not point to a valid framework HOT 2
- Publish new dot release HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swinjectautoregistration.