iOS编译错误:';没有可见的@interface;CDViewController';声明选择器
自从我将iOS项目切换到ARC后,我一直遇到以下编译器错误: “CDViewController”没有可见的@interface声明选择器 “setUseAgof:” 在这方面:iOS编译错误:';没有可见的@interface;CDViewController';声明选择器,ios,xcode,Ios,Xcode,自从我将iOS项目切换到ARC后,我一直遇到以下编译器错误: “CDViewController”没有可见的@interface声明选择器 “setUseAgof:” 在这方面: [self.viewController setUseAgof:false]; 在此文件中: AppDelegate.m #import "AppDelegate.h" #import "MainViewController.h" #import <Cordova/CDVPlugin.h> #import
[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
#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 <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
#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
#导入
#进口
#进口
@接口AppDelegate:NSObject{}
@属性(非原子,强)IBUIWindow*window;
@属性(非原子、强)IBOutlet CDVViewController*viewController;
@结束
确保AppDelegate
中的viewController
属性的类型为CDVViewController*
,而不是UIViewController*
viewController
的指针。您正在调用的方法是MainViewController
派生自CDVViewController
的类的一部分。被调用的方法是派生类的一部分,而不是基类,因此将viewController
指针改为MainViewController
。看起来不错:@property(非原子,强)IBOutlet CDVViewController*viewController代码>是否应该是MainViewController
?因为OP在MainViewController
接口中声明了函数。@Timo声明的方法是派生类的一部分,而不是基类。你明白问题吗?@Amar该死,你说得对!因此,在AppDelegate.h中,它必须是@property(非原子,强)IBOutlet MainViewController*viewController代码>-谢谢!如果你把你的建议作为答案发表,我会很高兴地把它标记为“正确答案”。