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

Getting the string value from the text field? #111

Closed
boldlion opened this issue Mar 13, 2019 · 1 comment
Closed

Getting the string value from the text field? #111

boldlion opened this issue Mar 13, 2019 · 1 comment

Comments

@boldlion
Copy link

boldlion commented Mar 13, 2019

I've read previous questions but I didn't quite understand how to get the string value. I tried the following but it returns an empty string:

cell.labelsField.onDidAddTag = { [weak self] _, _ in
      if let label = cell.labelsField.text {
          print(label)
          self?.labels.append(label)
     }
}

I want to able to get each value the user enters and then add it to an array. How can I do that?

@ricardopereira
Copy link
Member

@boldlion If you need an array of String then you can do tagsField.tags.map({$0.text}).

Even so, you can have access the value using the tag attribute sent to onDidAddTag:

cell.labelsField.onDidAddTag = { [weak self] field, tag in
    self?.labels.append(tag.text)
}

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