iOS编译错误:'CDViewController'没有可见的@interface声明选择器

时间:2013-08-28 10:16:32

标签: ios xcode

由于我将iOS项目切换为ARC,因此我不断收到此编译错误:

  

'CDViewController'没有可见的@interface声明选择器   'setUseAgof:'

在这一行:

[self.viewController setUseAgof:false];

在此文件中:

AppDelegate.m

#import "AppDelegate.h"
#import "MainViewController.h"
#import <Cordova/CDVPlugin.h>
#import "NSString+MD5.h"

@implementation AppDelegate

@synthesize window, viewController;

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
    // (...)
    [self.viewController setUseAgof:false]; // <-- HERE
    // (...)

    return YES;
}

@end

虽然方法是明确定义的:

MainViewController.h

#import <Cordova/CDVViewController.h>
#import <ADTECHMobileSDK/ADTECHMobileSDK.h>

@interface MainViewController : CDVViewController <ATInterstitialViewDelegate>{
    ATInterstitialView *interstitial;
}
- (void)setUseAgof:(BOOL)useAgofParam;
@end

@interface MainCommandDelegate : CDVCommandDelegateImpl
@end

@interface MainCommandQueue : CDVCommandQueue
@end

MainViewController.m

#import "MainViewController.h"

@interface MainViewController()
    - (void)setUseAgof:(BOOL)useAgofParam;
@end

@implementation MainViewController

BOOL useAgof = true;

- (void)setUseAgof:(BOOL)useAgofParam
{
    NSLog(@"1.) Setting useAgof = %d", (int)useAgofParam);
    useAgof = useAgofParam;
}

我不明白。怎么了?


更新

AppDelegate.h

#import <UIKit/UIKit.h>
#import <Cordova/CDVViewController.h>
#import <INFOnlineLibrary/INFOnlineLibrary.h>

@interface AppDelegate : NSObject <UIApplicationDelegate>{}

@property (nonatomic, strong) IBOutlet UIWindow* window;
@property (nonatomic, strong) IBOutlet CDVViewController* viewController;

@end

2 个答案:

答案 0 :(得分:0)

确保viewController中的AppDelegate属性的类型为CDVViewController *,而不是UIViewController *

答案 1 :(得分:0)

viewController似乎被声明为CDVViewController的指针。您正在调用一个方法,该方法属于从MainViewController派生的CDVViewController类的一部分。被调用的方法是派生类的一部分而不是基类,因此改为viewController的{​​{1}}指针。