Tagged Pointer

2018-07-19  本文已影响29人  伶俐ll
//如果是iOS平台,最高有效位是1(第64bit)
#define _OBJC_TAG_MASK (1UL<<63)
//如果是mac平台,最低有效位是1
//#define _OBJC_TAG_MASK 1UL

BOOL isTaggedPointer(id pointer)
{
    return ((uintptr_t)pointer &_OBJC_TAG_MASK)  == _OBJC_TAG_MASK;
}
思考以下2段代码能发生什么事?有什么区别?
dispatch_queue_t queue = dispatch_get_global_queue(0, 0);
for (int i = 0; i < 1000; i++) {
        dispatch_async(queue, ^{
            self.name = [NSString stringWithFormat:@"abcdefghijk"];
        });
 }  
dispatch_queue_t queue = dispatch_get_global_queue(0, 0);
 for (int i = 0; i < 1000; i++) {
        dispatch_async(queue, ^{
            self.name = [NSString stringWithFormat:@"abc"];
        });
 }   
上一篇下一篇

猜你喜欢

热点阅读