【发布时间】:2015-03-08 21:19:58
【问题描述】:
最近在研究在一个文件中创建多个类的可能性,为此我用一个.xib文件创建了一个UIViewController类,文件结构如下:
MyFristViewController.h
#import <UIKit/UIKit.h>
@interface MyFristViewController : UIViewController
@end
@interface MySecondViewController : UIViewController
@end
MyFristViewController.m
@implementation MyFristViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"Frist View Loaded");
}
@end
@implementation MySecondViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"Second View Loaded");
}
@end
我的疑问是:系统如何知道要执行名为 'MyFristViewController' 的类中包含的方法?
我已经尝试在界面生成器中修改自定义类,尝试更改类在文件中的位置,系统只继续运行 'MyFristViewController' 类中的现有方法,为什么?
【问题讨论】:
-
为什么不呢?清楚地划分了哪个类是哪个。文件名完全无关;它们只是对你的一种方便。完全不清楚你对什么感到惊讶。
标签: ios objective-c uiviewcontroller xib