我有代码(简化):
#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;
提前致谢。
答案 0 :(得分:0)
我通过另一个论坛找到了自己的答案。关键是在&
通过CFDictionaryRef
时使用CFFTPCreateParsedResourceListing
运算符。例如:
CFFTPCreateParsedResourceListing(kCFAllocatorDefault, listingBuffer, bufferLength, ¤tListingRef);