我對使用「CFStringRef」有疑問。我見過管理iPhone接觸的幾個例子,在大多數人,他們使用:使用鑄造而不是CFStringRef獲取聯繫信息
...
ABMultiValueRef emails = ABRecordCopyValue(person, kABPersonEmailProperty);
CFStringRef emailRef = ABMultiValueCopyValueAtIndex(emails, 0);
...
NSString *email = (NSString *)emailRef;
我不知道爲什麼CFStringRef被替代使用的鑄造:
...
ABMultiValueRef emails = ABRecordCopyValue(person, kABPersonEmailProperty);
NSString *email = (NSString *)ABMultiValueCopyValueAtIndex(emails, 0);
...
它是傳統的以使用CFStringRef?使用直接投射是否正確?
感謝您的回答。關於釋放內存,據我所知它需要釋放它(使用'CFRelease(emailRef)'),正如我在本指南中所見(https://developer.apple.com/library/mac/#documentation /CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html) – rai212