17.无缝桥接

NSArray *array1 = @[@1, @2, @3];
NSArray *array2 = @[@1, @2, @3];

// ARC任然具备Objective-c对象的所有权,不需手动释放
CFArrayRef arrayRef1 = (__bridge CFArrayRef)(array1);
NSLog(@"count = %ld", CFArrayGetCount(arrayRef1));

//  __bridge_retained == __bridge_retained
//  __bridge_retained意味着ARC交出对象所有权,要自己释放内存
CFArrayRef arrayRef2 = CFBridgingRetain(array1);
CFRelease(arrayRef2);

// CFArrayRef->NSArray

NSArray *array3 = (__bridge NSArray *)(arrayRef1);

你可能感兴趣的:(17.无缝桥接)