我正在学习iOS开发,我在互联网上找到了一个应用源代码示例。
我正在尝试重写它并将其用于选项卡式布局,并且在从示例应用程序复制AppDelegate.m
之后,我收到以下错误:
'FirstViewController'没有Visible @interface声明了选择器alloc
在以下行中:
FirstViewController *FirstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
这是我的完整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
我的selector InithWithNibName:bundle
文件
FirstViewController.m
)
MyViewController* MyController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
我不知道这个错误意味着什么。
答案 0 :(得分:1)
您应该为变量和类使用不同的名称。
变化:
var str = 'This* is a ** test string. **';
var count = (str.match(/\*/g) || []).length;
if (count >= 5) {
alert('doing something...')
}
else {alert(count);}
为:
FirstViewController *FirstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];