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
网友评论