Friday, 11 March 2016

Pass Data from one view controller to another using App Delegate

Here we are just declare some variable as a public in Appdelegate. Then we will store some value to that variable from any class. Which will accessible to all other class.

AppDelegate.h

@property (strong, nonatomic) NSString *login_id;
@property (strong, nonatomic) NSString *login_name;

Class1.m

#import "AppDelegate.h"


In Load

AppDelegate *del = (AppDelegate*)[[UIApplication sharedApplication] delegate];
del.login_id=@"1";
del.login_name=@"MyName";

Class2.m

In btnAction or may you use RowAtIndex for TableView

AppDelegate *obj_del = (AppDelegate*)[[UIApplication sharedApplicationdelegate];
NSLog(@"%@",obj_del.login_id);
NSLog(@"%@",obj_del.login_name);

No comments:

Post a Comment