I would like to get at
- (void)applicationWillTerminate:(UIApplication *)application
a variable from a view controller class.
I have build an tabbar application and only added the tabbar controller to the appdelegate.
[window addSubview:tabBarController.view];
How can i get an variable from the TestViewController:
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@interface TestViewController : UIViewController {
IBOutlet UILabel *testLabel;
NSString *currentString; //Value that i want to save at applicationWillTerminate
}
@property (nonatomic, retain) UILabel* testLabel;
@property (nonatomic, retain) NSString* currentString;
@end
It’s somewhat incidental that TestViewController hasn’t been dealloc’d by the time you reach applicationWillTerminate – it might make sense to store that value a level higher in your application. That approach would be to always store currentString in the UIApplicationDelegate so that you don’t have to fetch it later: