I know that injectParameterWith takes an id, but I'm fairly new to Objective-C and not sure of the interaction there. Here is a snippet to show my case:
return [TyphoonDefinition withClass: AWSServiceConfiguration.class
configuration:^(TyphoonDefinition *definition) {
definition.scope = TyphoonScopeSingleton;
[definition useInitializer:@selector(configurationWithRegion:credentialsProvider:) parameters:^(TyphoonMethod *initializer) {
[initializer injectParameterWith: AWSRegionUSEast1]; //compile error here
[initializer injectParameterWith: self.awsCredentialsProvider];
}];
}];
What should the correct usage be in this case?
You have to box your primitive as an NSNumber, using an '@' symbol, example @(AWSRegionUSEast1)
So your definition should be:
return [TyphoonDefinition withClass: AWSServiceConfiguration.class
configuration:^(TyphoonDefinition *definition)
{
definition.scope = TyphoonScopeSingleton;
[definition useInitializer:@selector(configurationWithRegion:credentialsProvider:)
parameters:^(TyphoonMethod *initializer)
{
[initializer injectParameterWith: @(AWSRegionUSEast1)]; //Hooray, compiles!
[initializer injectParameterWith: self.awsCredentialsProvider];
}];
}];
You can find more info on injecting configuration (primitives, structs cstrings, etc) in the User Guide here.