SEE EDIT AT BOTTOM
I am making a UtilityView
application for the iPhone and I want to be able to change values from the FlipsideViewController
. I have a problem that whenever I switch back to the MainView from the FlipsideView, the values of the text fields that I had changed in the FlipsideView are seemingly reset to 0. In the MainViewController.m
, under the flipsideViewControllerDidFinish:
playToInt = [controller.playTo.text intValue];
computerMoveSpeed = [controller.aiSpeed.text intValue];
The text field 'playTo' coordinates with the integer 'playToInt' and the text field 'aiSpeed' coordinates with the integer 'computerMoveSpeed'. I think this should save the values, even when the ViewDidLoad runs again, but they both seem to be reset to 0.
if (playToInt != 10 || computerMoveSpeed != 3)
{
playBool = true;
}
else
{
playBool = false;
}
I know that the boolean is working because I can change the integers' values with it, but they always default back to 0. Any help is appreciated. Thanks in advance.
NOTE: I have consulted the previous question 'Passing UISegmentedControl values from FlipSideViewController in an Utility application to the mainviewcontroller…' and that does not work for me... I am have too many possible values to use an index or a switch.
EDIT: I am trying something that I think is really close to working... I feel like it just has bad syntax or something... I have in the MainViewController.m:
computerMoveSpeed = [FlipsideViewController.aiSpeed.text intValue];
playToInt = [FlipsideViewController.playTo.text];
EDIT: I have something that is similar to the last one but I think it will have a better chance of working with some help...
in the FlipsideViewController.m
I have
_playToNumber = [_playTo.text intValue];
and in the MainViewController.m
playToInt = [controller.playToNumber];
Any help is greatly appreciated, but as some additional info, on the string in the MainViewController
it says it needs an identifier on the playToNumber
variable, but it is declared as int
... I don't know if there is an identifier for int
s but if there is, please let me know!
EDIT: Is there any way to save the values in a usable format for the MainViewController
using the prepareForSegue
function in the FlipsideViewController
?
EDIT: I figured out that it was just getting the initial values when it loaded the ViewDidLoad
, so I started using a timer to retrieve the values. This seems to be working, I just need to know how to access these values from the MainViewController
?