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

Issue with bidirectional bindings in NSTextField #68

Closed
rnine opened this issue May 21, 2015 · 5 comments
Closed

Issue with bidirectional bindings in NSTextField #68

rnine opened this issue May 21, 2015 · 5 comments

Comments

@rnine
Copy link

rnine commented May 21, 2015

I was trying to set a bidirectional binding on a NSTextField and I think I have spotted a bug (I am using Xcode 6.3. / Swift 1.2)

This is what I have:

@IBOutlet weak var textField: NSTextField!
let backedValue = Dynamic<String>("Moose")

func applicationDidFinishLaunching(aNotification: NSNotification) {
   backedValue <->> textField.dynText
}

When the textfield is changed, Bond attempts to trigger -[Bond.TextFieldDynamicHelper textChanged:] but it fails with "unrecognized selector sent to instance". After looking at Bond+NSTextField.swift I noticed that textChanged is declared as private:

Declarations marked private are not exposed to the Objective-C runtime if not otherwise annotated. IB outlets, IB actions, and Core Data managed properties remain exposed to Objective-C whatever their access level. If you need a private method or property to be callable from Objective-C (such as for an older API that uses a selector-based callback), add the @objc attribute to the declaration explicitly.

Perhaps adding @objc would be a good idea?

@juandent
Copy link

HI,

I reported this issue a while ago... I think adding @objc attribute makes the most sense since it allows us to keep it private

Regards,
Juan Dent

srdanrasic added a commit that referenced this issue May 23, 2015
@srdanrasic
Copy link
Contributor

Ok guys, should be fixed in v3.7.3. AppKit support is kind of still unofficial. Feel free to contribute if you need additional extensions.

@rnine
Copy link
Author

rnine commented May 23, 2015

@srdanrasic Unfortunately the changes in v3.7.3 did not fix this issue.

I noticed you added the @objc to the class rather than the private function, hence the situation has not changed (selector is still not recognised.)

    @objc private func textChanged(sender: AnyObject?) {
        self.listener?(control?.stringValue ?? "")
    }

This, however works as intended 👍

srdanrasic added a commit that referenced this issue May 23, 2015
@srdanrasic
Copy link
Contributor

Oh. Well, v3.7.4 is out :)

@rnine
Copy link
Author

rnine commented May 23, 2015

@srdanrasic Great, thank you! 👍

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

3 participants