0

So, if I give A to a text field, it should return that it's a character. If I write an integer, it should return that it's an integer. How do I do that in Swift?

  • 5
    The value of a text field is always a string. Can you give a clearer example of what exactly you're trying to do? – John Montgomery Aug 26 '20 at 21:33
  • @JohnMontgomery I want to make a text field in which I would put different types of texts like characters, whole numbers, integers, decimal containing numbers and when I enter those, I should get a corresponding answer as to what I entered basically is i.e if it's an integer it should give a pop-up message that what I entered is an Integer and so forth. – Saad Javaid Aug 26 '20 at 21:41
  • 1
    This might help you: [How to check is a string or number](https://stackoverflow.com/questions/26545166/how-to-check-is-a-string-or-number) – pawello2222 Aug 26 '20 at 21:55
  • 1
    What's the difference between "integer" and "whole number" here? What is a "decimal containing numbers?" (Are there decimals not containing numbers?) What is a "character" in this context? ("Character" has a specific meaning in Swift, which everything you're describing would include, so I assume you have a different meaning.) If the string is `123.` is that an integer? `123.0`? Is `$123` an integer? If `A` is a "character" is `%` a character? Is `ب`? `㧴`? Is `٢` an integer? Once you nail down what you mean, the code will likely be trivial. the hard part is deciding what you mean. – Rob Napier Aug 26 '20 at 23:45

0 Answers0