ハロの外部記憶インターフェイス

そろそろ覚える努力が必要かも…

バックグラウンドから戻った時のイベント処理

AppDelegateのイベント処理に対象ViewControllerを取得し、処理を実行する

AppDelegate

#import "AppDelegate.h"
#import "ViewController.h"

@implementation AppDelegate
/*....*/
- (void)applicationWillEnterForeground:(UIApplication *)application
{
  //バックグラウンドから画面へ戻る時のイベント
    ViewController *vc = (ViewController *)self.window.rootViewController;
    [vc myAction];
}
  1. AppDelegateに対象のViewController.hをimportする
  2. self.windows.rootViewControllerを取得し、対象コントローラの処理を実行する

ViewController

@interface ViewController : UIViewController

-(void)myAction;

@end
  1. ViewControllerのinterface定義で実行する処理を定義する