笔试题

作者: MoneyRobber | 来源:发表于2020-05-06 14:32 被阅读0次

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

相关文章

网友评论

      本文标题:笔试题

      本文链接:https://www.haomeiwen.com/subject/megnyqtx.html