Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initializer automatically injected by type #269

Closed
7ynk3r opened this issue Oct 29, 2014 · 2 comments
Closed

Initializer automatically injected by type #269

7ynk3r opened this issue Oct 29, 2014 · 2 comments

Comments

@7ynk3r
Copy link

7ynk3r commented Oct 29, 2014

For properties, the Objective-C run-time provides type-introspection. Therefore, injection can be done by matching the required-type, as follows:

- (Knight *)knight
{
    return [TyphoonDefinition withClass:[Knight class] configuration:^(TyphoonDefinition *definition) {
        [definition injectProperty:@selector(quest)];
    }];
} 

Why can't be the same be achieved by using an "initWith"? Some like this:

- (Knight *)knight
{
    return [TyphoonDefinition withClass:[Knight class] configuration:^(TyphoonDefinition *definition) {
        [definition useInitializer:@selector(initWithQuest:)];
    }];
} 
@alexgarbarev
Copy link
Contributor

Because Objective-C runtine doesn't provide information about argument type (which class) of methods. That information available only for properties

@7ynk3r
Copy link
Author

7ynk3r commented Oct 29, 2014

Makes sense. Thanks for the info!

@7ynk3r 7ynk3r closed this as completed Oct 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants