I want my application to reload data as soon as the application switches from background to foreground.
Here is my code:
DataAppDelegate.h
AppDelegate.m
#import "DataAppDelegate.h" #import "DataViewController.h" @implementation DataAppDelegate @synthesize window; @synthesize viewController; #pragma mark - #pragma mark Application lifecycle - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
DataViewController.h
@interface DataViewController : UIViewController<UIWebViewDelegate, ADBannerViewDelegate> { IBOutlet UIWebView *webView; IBOutlet UITextField *addressBar; IBOutlet UIActivityIndicatorView *activityIndicator; IBOutlet UILabel *myField2; IBOutlet UILabel *myField3; IBOutlet UILabel *myField4; IBOutlet UILabel *myField5; IBOutlet UILabel *myField6; ADBannerView *adView; BOOL bannerIsVisible; } @property(nonatomic,retain) UIWebView *webView; @property(nonatomic,retain) UITextField *addressBar; @property(nonatomic,retain) UIActivityIndicatorView *activityIndicator; @property(nonatomic,assign) BOOL bannerIsVisible; -(IBAction) goBack:(id)sender; -(IBAction) goForward:(id)sender; -(IBAction) refresh:(id)sender; -(IBAction) goImpressum:(id)sender; @end
DataViewController.m
- (void) viewDidLoad { [self loadData]; } - (void)loadData {
With this code, I get two warnings:
'DataViewController' may not respond to '+ refresh'
but it works.
If I cut a line in the method "applicationDidEnterBackground:" it no longer works, the application crashes. What for? How do I populate the applicationDidEnterBackground method :? Do I need to reserve a place for my application? how to do it?
How can I resolve these warnings? Apparently, my application does not know the update method, but why does it work in my example above?
Thanks in advance for your help :)
objective-c multitasking
Dwain
source share