0

I want to display the button.tag value in UITextField. For that I append the tapped button value in array. I initialized the array on top as

var inputString:Array = [String]()

Now I tried to put these array values in UITextField like this

        self.txtPassword.text = self.inputString

I tried this as I did earlier in objective c. But in swift I am unable to do this. Please someone give me solution. Thanks

4
  • Can you show your Objective-C code, and perhaps a sample of what you expect the value of the text field to be? Commented May 11, 2017 at 15:01
  • just inputString.joined() or inputString.joined(withSeparator: ", ") Commented May 11, 2017 at 15:02
  • This is my objective - c code [self.inputPassowrd appendString:[NSString stringWithFormat:@"%ld", (long)button.tag]]; self.txtPassword.text = self.inputPassowrd; Commented May 11, 2017 at 15:06
  • 1
    Thank you so much. .joined() worked :) Commented May 11, 2017 at 15:10

1 Answer 1

1

You are trying to attribute an array to a String. That will never work.

If you need one value of the array to be attributed to the textField, you need to know its index and do:

self.txtPassword.text = self.inputString[index]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.