【发布时间】:2014-11-06 16:19:47
【问题描述】:
这是我在 stackoverflow.com 上的第一个问题。 我正在尝试从 AppDelegate.m 中的 ViewController.m 调用方法 [- (void)alterTime]。是的,我在 AppDelegate.h 中有 #imported "ViewController.h"。将控制器导入 AppDelegate.m 没有任何区别。此外,“后台提取”已开启。
这是我正在尝试实现的 AppDelegate.m 中的代码:
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler
{
NSLog(@"Current Time Altered");
//Get current view controller
ViewController *mainViewController = (ViewController *)self.window.rootViewController;
[mainViewController alterTime];
//Cleanup
completionHandler(UIBackgroundFetchResultNewData);
}
这是给我带来问题的代码:
[mainViewController alterTime];
它声明:“'ViewController' 没有可见的@interface 声明选择器'alterTime'”。
【问题讨论】:
-
显示
ViewController.h
标签: objective-c methods uiviewcontroller appdelegate