-
Notifications
You must be signed in to change notification settings - Fork 268
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
By default, greedily choose the longest satisfiable constructor #36
Comments
This would be cool. . . how would it effect performance? If the impact is minimal (I would assume yes), then I'm good with it. |
Should be easy to implement and performant. I'm thinking just grab all the selectors, select those that begin with init, and pick the longest one. I'll see what I come up with. |
Note that the Objective-C runtime allows type introspection on properties/selector return values, but not for parameter arguments. . . Therefore it will still be necessary to a) declare parameters in the correct order or b) Specify an index |
Interesting limitation. Thanks for the heads up. |
I think the type introspection on method params limitation of objective-c would mostly kill this feature. Should we close? |
It could still be implemented without the satisfiable part, by defaulting to the constructor (identified via the init prefix) with the most arguments and still requiring you to call -injectWithDefinition. But on the other hand, by doing so you lose the clarity of seeing the selector in the initializer block. So you'd be calling -injectWithDefinition a few times and there would be no way (without jumping to the definition of the class you are instantiating) to notice if you're calling -injectWithDefinition with the correct parameters for the selector that is being used. I agree, it seems like allowing the omission of the selector given these limitations would invite more harm then good. |
"I think the type introspection on method params limitation of objective-c would mostly kill this feature. Should we close?" . . . Actually I don't know what I was thinking when I wrote that! It doesn't prevent the feature at all! . . All the same, I'd prefer the following:
This is quite possible with an AppCode plugin. . . not sure how to tackle it with Xcode. |
I agree, it seems like an IDE issue. I don't think we should change the semantics of the @selector directive, but providing some additional autocomplete in the initialization block would be great! Say, when choosing to autocomplete the block, automatically or manually pick the selector depending on ambiguity and then fill in the initializer.selector = line. |
I already get some of the way there using this live template in AppCode: return [TyphoonDefinition withClass:[$CLASS$ class] initialization:^(TyphoonInitializer* initializer) . . . pressing control-space on selector gives a huge list though. . . Having it default to one or show a list of options just for that class requires a plugin. . I've done some research into the plugin, and I think it would take 1-2 weeks of full-time work. . . . . . if a framework becomes popular, Jetbrains usually provide built-in support - installing the plugin by default. . . eg, as they've done for CocaoPods. On Sep 9, 2013, at 11:05 PM, Robert Gilliam notifications@github.com wrote:
|
Sounds like something for the future, then! Bigger fish to fry at the moment. :) |
Ala PicoContainer (see third from the top, How does PicoContainer decide what constructor to use?), this should reduce the number of instances in which you must manually set the selector on the initializer. It's particularly painful to do so, at least in Xcode, as the selectors suggested for autocomplete are not necessarily on the class you're actually trying to initialize.
The text was updated successfully, but these errors were encountered: