Casting CFDictionaryRef with pointer?
I have the code (simplified):
#define kSendBufferSize 32768
UInt8 listingBu开发者_如何学Pythonffer[kSendBufferSize];
NSDictionary *currentListing;
CFIndex bufferLength;
CFDictionaryRef currentListingRef;
CFFTPCreateParsedResourceListing(kCFAllocatorDefault, listingBuffer, bufferLength, currentListingRef);
currentListing = (__bridge NSDictionary *) currentListingRef;
on the last line, I receive the following warning in XCode:
"Incompatible pointer types passing 'CFDictionaryRef' (aka 'const struct __CFDictionary *')
to parameter of type 'CFDictionaryRef *' (aka const struct __CFDictionary **')"
The problem is that I need to declare the CFDictionaryRef with no pointer so that this line will work properly: (see Casting a CFDictionaryRef to NSDictionary?)
currentListing = (__bridge NSDictionary *) currentListingRef;
Thanks in advance.
I figured out my own answer through another forum. The key is to use the &
operator when passing the CFDictionaryRef
through the CFFTPCreateParsedResourceListing
. For example:
CFFTPCreateParsedResourceListing(kCFAllocatorDefault, listingBuffer, bufferLength, ¤tListingRef);
精彩评论