2014-09-12 5 views
0

이것은 내 첫 번째 질문은 stackoverflow.com입니다. AppDelegate.m의 ViewController.m에서 [- (void) alterTime] 메서드를 호출하려고합니다. 예, # import "ViewController.h"AppDelegate.h 있습니다. 컨트롤러를 AppDelegate.m으로 가져 오면 아무런 차이가 없습니다. 또한 "배경 가져 오기"가 켜져 있습니다.AppViewController 메서드에서 AppDelegate

[mainViewController alterTime]; 

그것은 상태 :이 코드의 조각을 나에게주는 문제가

- (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); 
} 

: 여기

내가 구현하기 위해 노력하고있어 AppDelegate.m 내부의 코드 없다 "눈에 띄는 'ViewController'의 @interface는 selector 'alterTime' "을 선언합니다.

+0

쇼'ViewController.h' –

답변

0

오류는 클래스 ViewController에있는 메서드 이름 (selector)을 찾지 못했음을 의미합니다.

ViewController 헤더에 alterTime 메서드가 선언되어 효과적으로 공개되도록하십시오.

괜찮아요 경우, 한 번 확인하여 rootViewController이 (소유) 유형 ViewController

+0

고맙습니다. 내 부주의로 인해 이번에는 실망하게되었습니다. – Krekin

+0

전혀 문제가 없습니다. :)가 발생합니다. –

0

ViewController.h 파일에 - (void)alterTime을 선언하십시오.

@interface ViewController : UIViewController 

- (void)alterTime; 

@end 
+0

쳇입니다 있는지 확인하기 위해, 나의 부주의 나 종료 될 것입니다. 나는 내 자신을 보지 못해 당혹 스럽다. 고맙습니다. – Krekin