I wish to transfer float values from one view controller to another. All the tutorials I can find only give examples of text transfers, not values.
I have a settings page which allows a user to click on buttons which have constant float
values, such as Tear = 0.13
, Engine = 0.15
, etc. I wish to transfer these values to the root view controller, once a button
is clicked on.
I have created a push segue, and added some code from a tutorial for the prepareforSegue:
of the implementation file of the source view controller.
Can anyone help me with the next step, which is the code for transferring float
values
from the source controller to the destination (root) controller.
Here's what I have so far in prepareforSegue:sender:
in the source view controller.
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier] isEqualToString:@"SendInfo"]) {
ViewController *detailViewController = [segue destinationViewController];
And this is how the CalcViewController
implementation file looks in the IBAction
area.
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
if ([[segue identifier] isEqualToString:@"SendInfo"]) {
ViewController *detailViewController = [segue destinationViewController];}
}
- (IBAction)WT2:(id)sender {
}
- (IBAction)WT:(id)sender {
float Tear=0.13;
}
- (IBAction)Car1:(id)sender {
float Litre=0.13;
}
- (IBAction)Car2:(id)sender {
float Litre=0.15;
}
- (IBAction)Car3:(id)sender {
float Litre=0.25;
}
- (IBAction)MP1:(id)sender {
float Net1=0.03;
}
- (IBAction)MP2:(id)sender {
}
@end