I am starting objective C and i want to make a form with text inputs. I have many Text Fields on my view and i want to check if the values written are good (only numbers, only text).
How can i do that? I found some documentation but not a lot… If anyone has a good ressource to help me to make forms.
I also want to know how to get all values in an array.
Thank you for help and sorry if my questions look terrible and easy.
I know ruby, php, javascript 🙂
Given a textfield called
textfield1, you can access its string content viatextfield1.text. This will yield a NSString-object which you can then analyze. You may use NSRegularExpression for this, or loop through 1-char-substrings or whatever you like, read up on NSString for this. A Google Search will also quickly yield you examples on how to use NSRegularExpressions.Seeing that you’re working for iOS, you might want to consider using special controls for your specific needs. For example, rather than using a textfield to request a number, and complain when the user inputs a non-number, present him a slider instead of a textfield.
For your second question, given an array
array1with NSString objects in it, you can loop through them by fast enumeration: