笔试题

UIViewController生命周期

load,initialize,init,loadView,viewDidLoad,viewWillAppear,viewDidAppear,dealloc

UIButton继承关系

UIButton,UIControl,UIView,UIResponder,NSObject

请写出一个单例

+(instancetype)sharedInstance {
    static id instance;
    static dispatch_once_t t;
    dispatch_once(&t,^{
        instance = [NSObject new];
    });
    return instance;
}

请说出以下代码的执行结果

- (void)viewDidLoad {
    dispatch_async(dispatch_get_main_queue(), ^{
        NSLog(@"A");
    });
    NSLog(@"B");
    dispatch_queue_t queuetmp = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0ul);
    dispatch_sync(queuetmp, ^{
        NSLog(@"C");
    });
    dispatch_async(queuetmp, ^{
        NSLog(@"D");
    });
    dispatch_async(dispatch_get_main_queue(), ^{
        NSLog(@"E");
    });
    [self performSelector:@selector(method) withObject:nil afterDelay:0];
    NSLog(@"F");
}

- (void)method {
    NSLog(@"G");
}

b
c
f

a
e
g

@interface Screen:NSObject
- (void)hello;
@end
@implementation Screen
- (void)hello {
    NSLog(@"%@",[self class]);
}
@end

@interface ScreenOne:Screen
- (void)hello;
@end
@implementation ScreenOne
- (void)hello {
    [super hello];
    NSLog(@"%@",[self class]);
}
@end

@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad {
    ScreenOne *test = [ScreenOne new];
    [test hello];
}

ScreenOne,ScreenOne

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容