__bridge_transfer和ABRecordCopyValue:和ARC [英] __bridge_transfer and ABRecordCopyValue: and ARC
问题描述
我正在访问地址簿并使用此行并使用ARC进行编译:
I'm accessing the address book and have this line and am compiling using ARC:
ABMultiValueRef phoneNums = ABRecordCopyValue(person, kABPersonPhoneProperty);
此行需要重写为:
ABMultiValueRef phoneNums = (__bridge_transfer ) ABRecordCopyValue(person, kABPersonPhoneProperty);
如果是,那么编译器是否应该生成警告?
如果没有,那么也许我不明白将ARC与核心框架结合使用。
If yes then shouldn't the compiler have generated a warning? If not then maybe I don't understand using ARC in conjunction with core framework thoroughly.
推荐答案
不,你在这种情况下不应该桥接。 ABMultiValueRef
是 CFTypeRef
。 ABRecordCopyValue
返回 CFTypeRef
。不需要桥接。
No, you should not bridge in this case. ABMultiValueRef
is a CFTypeRef
. ABRecordCopyValue
returns a CFTypeRef
. There is no bridge required.
当您在 id
和之间进行转换时,需要进行桥接转换CFTypeRef
(这是 void *
的同义词)。
Bridge casting is required when you convert between id
and CFTypeRef
(which is a synonym for void*
).
这篇关于__bridge_transfer和ABRecordCopyValue:和ARC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!