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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:26:00+00:00 2026-06-06T09:26:00+00:00

NSString is returning as NULL while Importing from ViewController Class were i want to

  • 0

NSString is returning as NULL while Importing from ViewController Class

were i want to import the string variable from 1st class to second class..but its not importing

please find met code below for your reference

ViewController:


@interface ViewController : UIViewController{

NSString * string;

@property(nonatomic, retain)NSString * string;

@end

@implementation ViewController
@synthesize string;

-(IBAction) login:(id) sender{
string = @"HI";
}

class2:

#import"ViewController.h"

@interface class2 : UIViewController{
ViewController * vc;
NSString * string1;

@property(nonatomic, retain)NSString * string1;

@end

@implementation ViewController
@synthesize string1;

-(IBAction) login:(id) sender{
NSLog(@"%@",vc.string);

@end
}

Where NSLog is returning NULL!!!!

Kindly help me!
Thanks in advance

  • 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-06T09:26:01+00:00Added an answer on June 6, 2026 at 9:26 am

    I am not clear about your code but if you want to send string from class1 to class2 then you can follow below method:

    1.Declare property in class2, same as you have declare:

    NSString * string1;
    @property(nonatomic, retain)NSString * string1;
    
    @synthesize string1;
    

    2.Then in class1 where you are navigating to class2 (from where you are initializing class2) just assign your string1 the required value as follows:

    class2Obj.string1 = @"Hi";
    

    and In class2 you can access string1.

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

Sidebar

Related Questions

[myDictionary objectForKey:kYourKey]; is returning NSString Object, but following code: if (![[myDictionary objectForKey:kYourKey] isEqualToString:@<null>]) {
I am having an issue with NSDictionary returning null for an NSString even though
i am trying to convert array object into string but still it is returning
Should I be retaining the responseData that I am returning // METHOD -(NSData *)dataFromTurbine:(NSString
NSString * string = @االْحَمْدُ لِلَّهِ رَبِّ الْعَالَمِينَ; const char *c = [string cStringUsingEncoding:NSUTF8StringEncoding];
NSString *phoneNumber = @2310234432; I would like to create a new string out of
My UITableView is returning EXEC_BAD_ACCESS , but why! See this code snippet! Loading the
i have a class method in which i am creating and returning the class
I want to delete a specific phone number from an address book contact. It
I have a NSString and I want to write its value to a NSMutableString.

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.