Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8224541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:06:20+00:00 2026-06-07T15:06:20+00:00

In my presenting view controller, I have the following prepareForSegue function – (void)prepareForSegue:(UIStoryboardSegue *)segue

  • 0

In my presenting view controller, I have the following prepareForSegue function

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if([[segue identifier] isEqualToString:@"goToView2"]){
        ViewController2 *controller2 = [segue destinationViewController];
        controller2.multiplierStepper.value = 7.0;
        controller2.randomString = @"string set from Scene 1";
    }
}

In ViewController2 there is an outlet for my UIStepper’s value and an NSString

@property (strong, nonatomic) IBOutlet UIStepper *multiplierStepper;
@property (strong, nonatomic) NSString *randomString;

In ViewController2.m viewDidLoad, I am testing the values set above by the presenting view controller

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.        
    NSLog(@"in viewDidLoad: self.multiplierStepper.value: %f", self.multiplierStepper.value);
    NSLog(@"in viewDidLoad: randomstring: %@", self.randomString);
}

The console output works nicely for the NSString, but the UIStepper value always shows the initial value defined in the Interface Builder (1).

[10682:f803] in viewDidLoad: self.multiplierStepper.value: 1.000000
[10682:f803] in viewDidLoad: randomstring: string set from Scene 1

The answer is probably glaringly obvious, but I cannot figure out how to set the value of a stepper in my destination view controller from the presenting view controller.

Any ideas what I’m doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:06:23+00:00Added an answer on June 7, 2026 at 3:06 pm

    Do not set directly the value of the UIStepper in the the prepareForSeque method , it will not work !

    You have to declare a property that will contains the value and then set the value of the stepper in the viewDidLoad event of the second controller …

    First of all declare an additional property to your second view controller (ViewController2) header file :

    @property (nonatomic) double stepperValue;
    

    Then set the property value :

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        if([[segue identifier] isEqualToString:@"goToView2"]){
            ViewController2 *controller2 = [segue destinationViewController];
            controller2.stepperValue = 7.0;
            controller2.randomString = @"string set from Scene 1";
        }
    }
    

    Then in the destination viewController (ViewController2) :

    - (void)viewDidLoad
    {
        multiplierStepper.value = [self stepperValue];
    }
    

    Note

    Bear in mind that the best thing for encapsulation would be declaring the IBOutlet as private member of the class, to avoid that a client of the class can access directly the IBOutlet; to make an IBOutlet private you have to declare it in a class extension in the .m file …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a modal view controller that I am presenting on iPad via: vc.modalPresentationStyle
How would I go about presenting a view controller that doesn't have a nib
I am presenting a modal view controller to show detailed information. I have it
I have a UIViewController (MyViewController) and another view controller i'm presenting modally though MyViewController
I have the following snippet of code: - (void)loadView { self.view = [[UILabel alloc]
I have a view controller (view A) presenting a modal view (B) when the
I have a view controller and I am presenting it modal, as in... UIViewController
I am presenting a table view in modal view controller created with the following
In my application I am presenting a modal view controller on top of the
I'm getting a white screen after presenting a modal view controller. This is how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.