简体   繁体   English

不可见的'MyController'的@interface声明了选择器

[英]Not visible @interface for 'MyController' declares the selector

I'm learning iOS development and I found an app source sample in the internet. 我正在学习iOS开发,并在互联网上找到了一个应用程序源示例。 I'm trying to rewrite it and use it for tabbed layout, and after copying the AppDelegate.m from the sample app, I got the following error: 我试图重写它并将其用于选项卡式布局,并从示例应用程序复制AppDelegate.m后,出现以下错误:

No Visible @interface for 'FirstViewController' declares the selector alloc 'FirstViewController'没有可见的@interface声明选择器alloc

In the following line: 在以下行中:

FirstViewController *FirstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];

This is my full AppDelegate: 这是我完整的AppDelegate:

#import "AppDelegate.h"

#import "FirstViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.

    FirstViewController *FirstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
    self.navigationController = [[UINavigationController alloc] initWithRootViewController:FirstViewController];
    self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
    self.window.rootViewController = self.navigationController;
    [self.window makeKeyAndVisible];
    return YES;
}

@end

same error (with selector InithWithNibName:bundle ) in my FirstViewController.m file 我的FirstViewController.m文件中出现相同错误(使用selector InithWithNibName:bundle

MyViewController* MyController  = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];

I don't know what this error means. 我不知道这个错误是什么意思。

You should probably use different names for your variables and classes. 您可能应该对变量和类使用不同的名称。

change: 更改:

FirstViewController *FirstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];

to: 至:

FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM