我有代码(简化版):
#define kSendBufferSize 32768
UInt8 listingBuffer[kSendBufferSize];
NSDictionary *currentListing;
CFIndex bufferLength;
CFDictionaryRef currentListingRef;
CFFTPCreateParsedResourceListing(kCFAllocatorDefault, listingBuffer, bufferLength, currentListingRef);
currentListing = (__bridge NSDictionary *) currentListingRef;
在最后一行,我在 XCode 中收到以下警告:
"Incompatible pointer types passing 'CFDictionaryRef' (aka 'const struct __CFDictionary *')
to parameter of type 'CFDictionaryRef *' (aka const struct __CFDictionary **')"
问题是我需要在没有指针的情况下声明 CFDictionaryRef,这样该行才能正常工作:(参见 Casting a CFDictionaryRef to NSDictionary?)
currentListing = (__bridge NSDictionary *) currentListingRef;
提前致谢。
最佳答案
我通过另一个论坛找到了自己的答案。关键是在通过 CFFTPCreateParsedResourceListing
传递 CFDictionaryRef
时使用 &
运算符。例如:
CFFTPCreateParsedResourceListing(kCFAllocatorDefault, listingBuffer, bufferLength, ¤tListingRef);
关于ios - 用指针转换 CFDictionaryRef?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7019514/