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 6140135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:04:42+00:00 2026-05-23T18:04:42+00:00

I am very new to xcode & Objective-C (having come from PHP) i have

  • 0

I am very new to xcode & Objective-C (having come from PHP) i have started to play around and am finding it very hard to pass variables between views this is what i have so far:

Game_info.h

#import <UIKit/UIKit.h>

@interface Game_Info : UIViewController {
    IBOutlet UITextField *groupName;
    IBOutlet UISegmentedControl *gameType;

}

@property (nonatomic,retain) IBOutlet UITextField *groupName;


- (IBAction) GameTypePicker;
- (IBAction) KeyboardHide;
- (IBAction) BackBTN;
- (IBAction) NextBTN;

@end

Game_Info.m

#import "I_Dare_YouViewController.h"
#import "Game_Info.h"
#import "Game_TDoR.h"


    @implementation Game_Info
    @synthesize groupName;


// Next Button
-(IBAction) NextBTN{
    if ([groupName.text length] == 0) {
        // Alert
        UIAlertView *alert = [[UIAlertView alloc] 
                              initWithTitle:@"Group Name" 
                              message:@"Please enter a group name" 
                              delegate:self 
                              cancelButtonTitle:@"OK" 
                              otherButtonTitles:nil
                              ];
        [alert show];
        [alert release];
    }else if([groupName.text length] < 3){
        // Alert
        UIAlertView *alert = [[UIAlertView alloc] 
                              initWithTitle:@"Group Name" 
                              message:@"Please enter a name longer than 3 characters" 
                              delegate:self 
                              cancelButtonTitle:@"OK" 
                              otherButtonTitles:nil
                              ];
        [alert show];
        [alert release];
    }else{
        Game_TDoR *screen = [[Game_TDoR alloc] initWithNibName:nil bundle:nil];
        screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        [self presentModalViewController:screen animated:YES];
        [screen release];

        Game_TDoR *screen1 = [[Game_TDoR alloc] initWithNibName:nil bundle:nil];
        NSLog(@"Game_Info: %@",self.groupName.text);
        screen1.groupNameText = self.groupName.text; 
        [self presentModalViewController:screen1 animated:YES];
        [screen1 release];

    }
}

Then in another view / .h / .m file i am trying to get to the ‘groupName’ property.

Game_TDoR.m

#import "I_Dare_YouViewController.h"
#import "Game_Info.h"
#import "Game_TDoR.h"
@implementation Game_TDoR
@synthesize groupNameText,Testlbl;


- (void)viewDidLoad
{
    NSLog(@"Game_TDoR: %@",self.groupNameText);
    NSString *msg = [[NSString alloc] initWithFormat:@"Hello, %@",[self.groupNameText capitalizedString]];
    [Testlbl setText:msg];
    [msg release];

    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

So what i am trying to do is on the first view page (Game_info) there is an input text box and im trying to pass that to a label on another view page (Game_TDoR)

This is what comes out in the NSLog (note that the second page (Game_TDoR) comes out first in the log.

2011-07-17 00:25:34.765 I Dare You[3941:207] Game_TDoR: (null)
2011-07-17 00:25:34.774 I Dare You[3941:207] Game_Info: Name

Problem solved:

On the next button i needed to add the variable before i moved page (not the other way around – silly noobish thing to do…)

        Game_TDoR *screen1 = [[Game_TDoR alloc] initWithNibName:nil bundle:nil];
        NSLog(@"Game_Info: %@",self.groupName.text);
        screen1.groupNameText = self.groupName.text; 
        [self presentModalViewController:screen1 animated:YES];
        [screen1 release];

        Game_TDoR *screen = [[Game_TDoR alloc] initWithNibName:nil bundle:nil];
        screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        [self presentModalViewController:screen animated:YES];
        [screen release];
  • 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-05-23T18:04:42+00:00Added an answer on May 23, 2026 at 6:04 pm

    If you need to pass the value of groupName.text from the Game_Info view controller to the Game_TDoR view controller, which is presented modally by the former, you can declare a property in Game_TDoR to hold the value:

    1) Declare a NSString property in Game_TDoR @interface block:

    @property (nonatomic,copy) NSString *groupNameText;
    

    (Remember to synthesize or implement the accessor methods in the implementation block)

    2) In NextBTN action, after you initialize your Game_TDoR instance, set the property:

    Game_TDoR *screen = [[Game_TDoR alloc] init...];
    screen.groupNameText = self.groupName.text;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I am very new to Web Programming. I have been learning PHP from
I am VERY new to ASP.NET. I come from a VB6 / ASP (classic)
Since new Xcode 3.2 I find it very hard to add Quartz Core Framework.
Im very new to Objective-C and am currently learning how to use Xcode and
I still very new using Subversion. Is it possible to have a working copy
I am very new to creating webservers - and I have had several goes
I'm VERY new to WPF, and still trying to wrap my head around binding
Hi I'm very new to sql but have been passed a job in which
Im very new to game development on the iPhone... And I have a question:
I am very new to IPhone development. I have upgraded my IPhone to the

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.