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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:15:32+00:00 2026-06-12T08:15:32+00:00

I have to pass a string value from one view to a label in

  • 0

I have to pass a string value from one view to a label in other view. But when I do such thing the label value is null. Could not understand where I am going wrong? Here is my code:

In FirstViewController.m

SecondViewController *gp=[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:[NSBundle mainBundle]];
gp.d.text = [NSString stringWithFormat:@"%@", nam];
[self.view addSubview:gp.view];
[gp release];

In SecondViewController.h

@interface SecondViewController : UIViewController<NSXMLParserDelegate>
{
    UILabel *d;
}

@property (nonatomic,retain) IBOutlet UILabel *d;

In SecondViewController.m
@synthesize d;

- (void)viewDidLoad
{
     NSString *urlString1 = [NSString stringWithFormat: @"http://192.168.0.108:8732/Design_Time_Addresses/ICloudServices/AppointmentService/json/GetProviders/?cid={%@}", [d text]];
}

But here the value of d is not passed. Why I dont understand. Where am I going 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-12T08:15:34+00:00Added an answer on June 12, 2026 at 8:15 am

    At the time of passing value to IBOutlet UILablel before adding subview is not allocated (has no memory reference).

    So better way is to pass your value after adding subView.

    [self.view addSubview:gp.view];
    gp.d.text=[NSString stringWithFormat:@"%@",nam];
    

    EDIT: better way is to pass string is like this:

    Create property of NSString in SecondViewController say yourString.
    

    Now

    SecondViewController *gp=[[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:[NSBundle mainBundle]];
    gp.yourString = [nam retain];
    [self.view addSubview:gp.view];
    

    Now in viewDidLoad of SecondViewController do this:

    self.d.text = self.yourString;
    

    Use yourString anywhere as per your requirement.

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

Sidebar

Related Questions

I have been trying to pass a string value from one method into another.
i want to pass a string value from one page to another.Also i have
We are using JSF 2.0. We have to pass in view parameters from one
If I have the value 0.0042 returned and I pass this to: string.Format({0:C},....); It
I'm trying to pass a string to chdir(). But I always seem to have
I have a method that hash input string to generate MD5 pass from it
I am using XML parser.In that i have to pass one id from one
I have a need of one DependencyProperty from a View in my ViewModel constructor:
Possible Duplicate: How to pass a value from one Activity to another in Android?
I have one view where I read json data. and extract keys from it.

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.