用指针强制转换CFDictionaryRef?

时间:2011-08-11 00:24:59

标签: ios ios4 casting ftp nsdictionary

我有代码(简化):

#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;

提前致谢。

1 个答案:

答案 0 :(得分:0)

我通过另一个论坛找到了自己的答案。关键是在&通过CFDictionaryRef时使用CFFTPCreateParsedResourceListing运算符。例如:

CFFTPCreateParsedResourceListing(kCFAllocatorDefault, listingBuffer, bufferLength, &currentListingRef);