我有@property NSDate
實例,它在方法- (void)applicationWillResignActive:(UIApplication *)application
中獲得時間。如何在AppDelegate和SecondViewController之間傳遞數據
我有ViewController
和SecondController
連接到Storyboard
所以在代碼中的AppDelegate實現塊我沒有任何ViewController和SecondViewController實例。方法- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
只返回YES。
的問題是:我必須從@property NSDate
實例傳遞時間,當應用程序被激活時顯示SecondViewController
,但我不知道我怎麼可以檢查,如果應用程序來自於背景後SecondViewController
顯示。
我知道,我可以使用的AppDelegate:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
然後得到他的NSDate @property
,但我怎麼能檢查的時候我一定要得到這個數據?
我應該使用哪種方法ViewController
?
問題是,當我''SecondViewController'添加viewWillAppar'NSLog':'方法我看不到任何結果..當我點擊的家,當我回來時顯示得那麼'viewWillAppear'不叫這個視圖。 –
這很奇怪。什麼導致使用'SecondViewController'?如果它是一個SEGUE,是什麼觸發了SEGUE ...代碼或某個用戶操作? –
是的,我有'ViewController'和'UITableView'。當我選擇Cell時,通過Modal Segue應用程序顯示SecondViewController。而當這個'SecondViewController'顯示我想鎖定的iDevice,但是當我這樣做,那麼'AppDelegate'獲取日期我這樣做的時候,當應用程序被激活我想從'AppDelegate'獲取數據和'SecondViewController'編輯。任何'viewWill ...'或'viewDid ...'不與'SecondViewController'工作:/ –