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

  • Home
  • SEARCH
  • 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 8210447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:04:29+00:00 2026-06-07T10:04:29+00:00

VC1 = NewGameViewController VC2 = GameViewController NewGameViewController.m – (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if( [segue.identifier

  • 0

VC1 = NewGameViewController
VC2 = GameViewController

NewGameViewController.m

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if( [segue.identifier isEqualToString:@"newGameSegue"]) {
    GameViewController *gameVC = (GameViewController *)segue.destinationViewController;

    NSArray *array = [self nameArrayForTextFieldArray:self.namePicker.textFieldArray withColon:YES];
    gameVC.nameArray = [[NSArray alloc] initWithArray:array];
}

-(NSArray *)nameArrayForTextFieldArray:(NSArray *)array withColon:(BOOL *)bool
basically returns an nsarray of strings given an nsarray of textfields. withcolon is a bool of whether or not you want the strings to have a colon appended to the end.

when i debug my code, the _nameArray ivar in gameVC still reads nil after every line here is called…can anyone help me out here??

  • 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-07T10:04:30+00:00Added an answer on June 7, 2026 at 10:04 am

    The prepareForSegue method is invoked by UIKit when a segue from one screen to another is about to be performed. It allows us to give data to the new view controller before it will be displayed. Usually you’ll do that by setting its properties.

    The new view controller can be found in segue.destinationViewController. If GameViewController embed the navigation controller, the new view controller will not be GameViewController but the navigation controller that embeds it.
    To get the GameViewController object, we can look at the navigation controller’s topViewController property. This property refers to the screen that is currently active inside the navigation controller.

    To send an object to the new view controller you can use this solution using performSegueWithIdentifier:

    For example, if we want to perform a segue pressing a UIButton we can do this:

    In the MyViewController.h we create a IBAction (connected to UIButton), dragging the button from storyboard to code:

    - (IBAction)sendData:(id)sender;
    

    In MyViewController.m we implement the method:

    - (IBAction)sendData:(id)sender
    {
        NSArray *array = [self nameArrayForTextFieldArray:self.namePicker.textFieldArray withColon:YES];
        [self performSegueWithIdentifier:@"newGameSegue" sender:array];
    }
    
    
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        if ([segue.identifier isEqualToString:@"newGameSegue"]) {
            UINavigationController *navigationController = segue.destinationViewController;
            GameViewController *controller = (GameViewController *)navigationController.topViewController;
            controller.nameArray = sender;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My data is just number, I want pass it from VC1 to VC2 for
i create an iPad app where i have three custom UIViewController. VC1, VC2, VC3.
I have 4 views embedded in a Navigation Bar: VC1 -> VC2 -> VC3
I have a UINavigationController with a UIViewController (vc1) as the root view controller. There
I've got a view controller, call it VC1, that's a table view. When I
how do i add a navigationViewController to a UIViewController? - (void)applicationDidFinishLaunching:(UIApplication *)application { loginViewController
Over here http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/TabBarControllers/TabBarControllers.html at listing 4.1 - (void)applicationDidFinishLaunching:(UIApplication *)application { tabBarController = [[UITabBarController alloc]
I have two view controllers. The flow between them is as follows: VC1 creates
I have setup a delegate method, so that when user selects cell from VC2,
I want to allow a pushed to set parentViewController's instance variables. For instance, VC1

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.