I need to pass NSString data from AppDelegate.m inside didReceiveRemoteNotification method and send it to my ViewController. I need to put NSLog inside viewDidAppear every time i receive a notification.
This is an expansion to @Himanshu's answer, if you're getting your
NSString in your
AppDelegate and it's something which you needs to preserve for further use, you can create a property and store it. There are multiple ways which you can follow to store / retrieve the values (example:
NSDictionary). So choose the one which will make your life easy in future.
Then you can get a shared object for your
AppDelegate and access to that property.
Adding his code to make this for future readers.
Add a property in your
@property (strong, nonatomic) NSString *strResponse;
Add this in top of the
AppDelegate.h (after import statement)
#define theAppDelegate ((AppDelegate *)[UIApplication sharedApplication].delegate)
Update string value.
self.strResponse = @"some response";
theAppDelegate.strLoadApi = @"some good response";
You can access it whenever requires.
P.S. This is not the best way to do achieve this. It's actually not recommended but I believe, you're learning iOS. So it's basic for you to start. However, you should read this answer to make your self ready for the future development.