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

Bind error #12

Closed
rmvz3 opened this issue Jun 11, 2017 · 7 comments
Closed

Bind error #12

rmvz3 opened this issue Jun 11, 2017 · 7 comments

Comments

@rmvz3
Copy link

rmvz3 commented Jun 11, 2017

Hi. Thank you for your work. I've been looking for a library just like yours. It's great for implementing MVVM without having to add RxSwift and so.

I'm getting an error when I try to use the bind function. For instance, if I write:

bind(wsSuccess, to: model.wsFBSuccess) //both properties are Observable(false)

I get a Xcode error saying "Missing argument for parameter #3 in call". I don't know if you have changed the function signature from the one appearing in the readme but autocomplete is only offering me: bind(Int32, UnsafePointer!, socklen_t) which seems unrelated to your library.

What am I doing wrong?

@smeis
Copy link
Contributor

smeis commented Jun 12, 2017

Hi @rmvz3,

It looks like your code should compile just fine, the function signature hasn't changed. Did you use Carthage or Cocoapods to add Hanson to your project? And do you have an import Hanson statement at the top of your file?

@rmvz3
Copy link
Author

rmvz3 commented Jun 12, 2017

I'm using Cocoapods. Hanson is imported and Observable properties works fine but the bind function is not accepted. It's weird but I've just realized that it works in other places. Take a look at this screenshot. It tries to bind the same properties from different classes.

http://imgur.com/a/72qJe

@smeis
Copy link
Contributor

smeis commented Jun 12, 2017

That's weird indeed! Have you tried rebuilding the project after cleaning, removing the derived data and reinstalling the pod?

If that doesn't work, can you discern any regularities in this error popping up in your project? The FacebookManagerDelegate is a protocol right? Could you check if binding works in other classes that are not a subclass?

@rmvz3
Copy link
Author

rmvz3 commented Jun 13, 2017

I've already tried the cleaning with no success. I think I found the reason. It seems that the problem arises just in classes that are not inherited from UIKit or Foundation. I don't know if this is an intentional behavior but at least there's an easy workaround

@smeis
Copy link
Contributor

smeis commented Jun 13, 2017

Ah yes, that's true. Any class that is a subclass of NSObject conforms to Observer through this extension. The Observer protocol has been extended with the bind function, so on any subclass of NSObject you can simply call bind and it works out of the box. Sadly this is not the case for classes that do not inherit from NSObject.

You could use Hanson on your LoginFacebookVM class by making it conform to the Observer protocol. However, I've noticed a mistake on our end. We didn't make the init method of ObservationManager public and you need to be able to create an observation manager to conform to the Observer protocol. I'll create a PR to fix this. Apologies!

@rmvz3
Copy link
Author

rmvz3 commented Jun 13, 2017

Thank you, Eric. I'm glad this has served to help to improve the code :)

@rmvz3 rmvz3 closed this as completed Jun 13, 2017
@smeis
Copy link
Contributor

smeis commented Jun 13, 2017

You're more than welcome @rmvz3! Thank you for contributing!

I've published the updated podspec.

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