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

Added the rex_textSignal to UITextField #80

Merged
merged 3 commits into from
Jan 22, 2016

Conversation

RuiAAPeres
Copy link
Member

No description provided.

/// Sends the field's string value whenever it changes.
public var rex_textSignal: SignalProducer<String, NoError> {
return NSNotificationCenter.defaultCenter()
.rac_notifications(UITextFieldTextDidChangeNotification, object: self)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't considered this with the NSTextField version, but doesn't this create a circular reference that leaks the text field?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am testing it here, it seems fine, but on the other hand rex_pressed seems to be leaking:
screen shot 2016-01-22 at 00 50 57

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's more to the retain cycle above than just rex_pressed since I've already got tests around that. I'm assuming that something with viewModel.authenticate is causing the problem.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good though, was worried about the notif center retaining the passed in object which it doesn't seem to be.

neilpa added a commit that referenced this pull request Jan 22, 2016
Added the rex_textSignal to UITextField
@neilpa neilpa merged commit b009e75 into RACCommunity:master Jan 22, 2016
@RuiAAPeres
Copy link
Member Author

Re-tested with only a UITextField:

        textField.rex_textSignal.startWithNext {
            print($0)
        }

And no leaks. 🐥

@RuiAAPeres
Copy link
Member Author

Btw, I re-checked and the leak is coming from here:

        let username = NSUserDefaults.value(forKey: .Username)
        let password = NSUserDefaults.value(forKey: .Password)

If instead of this I just use regular strings, there are no leaks. 👍

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

Successfully merging this pull request may close these issues.

2 participants