Hello all,
I have a simple Objective C question. I am trying to create a relatively simple program in Xcode as my first venture with Objective C. I have only programmed with Java in the past. What I want to do is get the text of a text field, convert it to an int (the text in the textfield is a number) then increase that integer by one and convert it back into a string to be displayed in the textfield. In Java, this is what the code would look like:
What are the commands to do this in Objective C?
Thanks in advance,
JOD8FY
P.S. - Not sure if this is necessary, but it's programmed in Cocoa.
I have a simple Objective C question. I am trying to create a relatively simple program in Xcode as my first venture with Objective C. I have only programmed with Java in the past. What I want to do is get the text of a text field, convert it to an int (the text in the textfield is a number) then increase that integer by one and convert it back into a string to be displayed in the textfield. In Java, this is what the code would look like:
Code:
//grab the integer of the text field, it is a string so we convert it to an integer value
int val=Integer.parseInt(textField.getText());
val++;
//Convert val back to a string and put it back in the value textfield
textField.setText(Integer.toString(val));
What are the commands to do this in Objective C?
Thanks in advance,
JOD8FY
P.S. - Not sure if this is necessary, but it's programmed in Cocoa.