I am really new to IOS developments. I know this is a silly question, but I really have no idea about this. I have two classes. lets assume A and B. in class A, I have a variable called x. I need to use this variable x in my class B. how can I do this?. please explain me with code samples
here is my code in login.h
#import <UIKit/UIKit.h>
#import "jsonpaser.h"
@interface LoginView : UIViewController
{
NSString* PERSON_ID;
}
@property (strong,nonatomic) IBOutlet UIScrollView *scroler;
@property (strong, nonatomic) IBOutlet UITextField *userName;
@property (strong, nonatomic) IBOutlet UITextField *passWord;
@property (strong,nonatomic) jsonpaser* jp;
@property(nonatomic,retain) NSString* PERSON_ID;
@end
in my login.m class there is a method.inside that method i set some value to my PERSONID variable
PERSON_ID = [[responseObject valueForKey:@"d"]objectForKey:@"PersonId"];
here is my tableviewcontroler.h class
#import <UIKit/UIKit.h>
#import "LoginView.h"
@interface TableViewController : UITableViewController <UITableViewDataSource>
{
LoginView* classobj;
NSString* personIDFromLogin;
}
@property (strong,nonatomic) NSArray* googlePlaces;
@property (strong,nonatomic) NSArray* finishedArray;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *sidebarButton;
@property(retain,nonatomic) LoginView* classobj;
@property(retain,nonatomic) NSString* personIDFromLogin;
@end
this is my tableview.m class
- (void)viewDidLoad
{
[super viewDidLoad];
LoginView* login = [[LoginView alloc]init];
NSString* x = login.PERSON_ID;
NSLog(@"X Variable : %@",x);
NSString* webPath = @"GetAppointmentRequests";
NSString* webURL = [NSString stringWithFormat:@"%@%@",BaseURLString,webPath];
NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys:x,@"caregiverPersonId", nil];
NSLog(@"PARAMETERS :%@",personIDFromLogin);
jsonpaser* parser = [[jsonpaser alloc]init];
[parser getWebServiceResponce:webURL :params success:^(NSDictionary *responseObject){
}];
}
EDIT
i have solve my problem with below link... thank you everyone. sorry for my bad english and grammar mistakes. refer this