xcode iOS 编译错误:“CDViewController”没有可见的@interface 声明了选择器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18485134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS compile error: No visible @interface for 'CDViewController' declares the selector
提问by Timo
Since I switched my iOS project to ARC, I keep getting this compiler error:
自从我将 iOS 项目切换到 ARC 以来,我不断收到此编译器错误:
No visible @interface for 'CDViewController' declares the selector 'setUseAgof:'
“CDViewController”没有可见的@interface 声明了选择器“setUseAgof:”
In this line:
在这一行:
[self.viewController setUseAgof:false];
In this file:
在这个文件中:
AppDelegate.m
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
Although the method is definitely defined:
虽然方法是明确定义的:
MainViewController.h
主视图控制器.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
主视图控制器.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;
}
I don't get it. What's wrong?
我不明白。怎么了?
Update:
更新:
AppDelegate.h
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
采纳答案by Amar
viewController
seems to be declared as pointer of CDVViewController
. You are calling a method which is part of MainViewController
the class derived from CDVViewController
. Method being called is part of derived class and not the base class, hence make viewController
pointer of MainViewController
instead.
viewController
似乎被声明为的指针CDVViewController
。您正在调用一个方法,该方法是MainViewController
从CDVViewController
. 被调用的方法是派生类的一部分而不是基类,因此使用viewController
指针 MainViewController
代替。
回答by Mike Kwan
Make sure the viewController
property in your AppDelegate
has a type of CDVViewController *
rather than UIViewController *
.
确保viewController
您的属性AppDelegate
具有类型CDVViewController *
而不是UIViewController *
。