面试题

2016-06-20  本文已影响6人  英雄出少年
synthesize 和 dynamic区别 ?
是否可以把比较耗时的操作放在NSNotificationCeter ?

如果在异步线程发的通知,可以处理耗时操作
如果在主线程发的通知,不可以处理比较耗时的操作

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dealTest) name:@"test" object:nil];
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)dealTest
{
    NSLog(@"dealTest-----%@", [NSThread currentThread]);
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSLog(@"%@-----", [NSThread currentThread]);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"test" object:nil userInfo:nil];
    });
}

@end
Foundation对象与Core Foundation对象有什么区别 ?
left 与leading的区别 ?
leading&trailing.png
上一篇 下一篇

猜你喜欢

热点阅读