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
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:
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:
and In class2 you can access string1.