-
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
You can't call a method on the runtime argument being passed in. It has to be passed in as-is #233
Comments
You can do so following this process. I'm sorry, but until just now this was missing from the docs. Let us know when you're all good, so we can close the issue. Or, if you still have problems and you'd like to share your assembly config, you can:
(or post it here if you like) |
Thanks a lot. I am also wondering how I can unit test my assembly files? Is there any way to inject mocks? |
There are also a ton of Selector not found warnings. Seems like I have to do extra casting just to get those warnings away (I can also just use the #pragmas but that doesn't seem like the best solution here). What's the best way to do this and your recommended way when using Typhoon Assemblies? |
Selectors: Typhoon tests necessarily have these warnings (testing invalid names etc). Under normal use you shouldn't see such warnings. Something is wrong. Testing: Well there are two approaches to testing at the API level. Unit Testing: Testing a class in isolation from its collaborators using mocks are stubs. Unit Test Disadvantages:
Integration Test Advantages:
Now recently there's been renewed discussion on when to use integration tests vs unit tests. Ruby's founder published an article called "TDD is dead", which despite the intentionally controversial title was more about unit testing vs integration testing. He sees value following the natural progression of the application. So if you have a discrete unit of course its going to be a unit test. If you have a class that's all about joining collaborators together and orchestrating a process, then naturally favor integration testing. Of course some integration tests can be difficult to set up: Getting the system into the required state, starting with a valid user, rolling back the results, etc. Fortunately the dependency injection pattern encapsulates configuration, so you can swap out one component for another. There's two main ways to do this with Typhoon:
Summary:
There's another DI container or two that allows you to inject all mocks in place of real collaborators. We like to have you provide the mocks because the expectations for each test scenario will be different. (A problem with stubs is that if you try to write one that supports all test scenarios, then they can become brittle). Mocks vs stubs described here: http://martinfowler.com/articles/mocksArentStubs.html |
Regarding the selector issue, do you have any suggestions on things I can look at fixing? Here's an example of my assembly file that exhibits this issue:
|
As long as the class containing the selector is in the target's compile phase, it will be registered. Is it? |
Yes it is. Everything compiles and runs fine at runtime. I only get these warnings at compile time. |
Odd. And all imported? You can work around this using: sel_registerName("initWithFoo:bar:baz:"); . . . but more importantly should find out why this is happening. |
Selector warning appears only on unknown selectors - you have to import heards which declare selector you use |
Also can use assembly interface without __weak cast for 'self'. it is unnecessary. There is no retain cycle on self |
All of the imports are there...but doesn't seem to make any difference. Cmd+Click takes me to the right selector... |
@ronak2121 could you share example project with these warning. I want to check why it happens.. |
Sure. The main thing I'm doing are forward declarations in my Assembly.h and #imports in the .m. I'm not sure if that matters at all. |
Using forward declarations wherever possible in header files is encouraged. It won't cause the issue you've described. If you would like to share your assembly you can post it here, or email it privately to [email protected] |
Hi Jasper, I emailed you my assembly files the other day like you asked. Please let me know what you suggest to fix the warnings. Thanks On Wednesday, June 11, 2014 11:13 AM, Jasper Blues [email protected] wrote: Using forward declarations wherever possible in header files is encouraged. It won't cause the issue you've described. |
What was the date + email subject? I don't think we received anything. |
I sent it on Wednesday the 11th. Subject is "assembly files for lots of selector warnings" |
I resent the email to you guys again over the weekend with the same subject. Hopefully you received it? |
Received, thanks. Will get back to you ASAP. |
Hi Jasper, I know you are pretty busy; but was wondering if you had a chance to look at my assembly? Thanks. |
Ping? |
I saw you email today, it is set of assembly files. All looks correct (except *__weak weakSelf = self; - weakify self is unnecessary, since block is not retained). |
@ronak2121 ping? |
I'll try to fit making a test project into my schedule. I have other competing things going on. On Thursday, June 26, 2014 2:29 AM, Aleksey Garbarev [email protected] wrote: @ronak2121 ping? |
Ok, thanks. Will wait for example project |
Reproduced: In an Assembly you should use #import instead of forward declarations. |
Ahhhhh okay I will fix that thank you! On Friday, June 27, 2014 6:40 AM, Jasper Blues [email protected] wrote: Reproduced: In an Assembly you should use #import instead of forward declarations. |
So I removed all of my forward declarations in favor of #import; however these warnings are still there. Do I need to #import in the .h and the .m? |
I thought assembly files has imports in .m files - so all was ok.. Still waiting for example project, because project includes compiler settings(warning settings) and its easy to reproduce |
Normally you should use forward declarations in headers, and imports in .m files, except for the following:
Recently, I ran into another situation where I had to #import a class in a TypyhoonAssembly header (first time). I guess it had to do with the compile order. . . I just did it for the one effected file. Otherwise, I'd get the unrecognized selector error. Alternative: sel_registerName("initWithFoo:bar:baz:"); //Tell the compiler about the selector it hasn't encountered yet. |
Closing. |
I'm in the process of upgrading from Typhoon 1.8.6 to 2.0.7 and writing my Assemblies, but I'm greeted by this error whenever I launch.
I have about 20 view controllers in my application. These view controllers extend a base view controller we have that declares a bunch of dependencies.
Naturally, I am looking to share the code to set these dependencies as well.
I tried making a private shared method which sets these but it results in the above exception at run time.
Is the preferred way to have a definition defined in the assembly for the base class itself?
Thanks
Ronak
The text was updated successfully, but these errors were encountered: