ios - 用指针转换 CFDictionaryRef?

标签 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;

提前致谢。

最佳答案

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

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

关于ios - 用指针转换 CFDictionaryRef?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7019514/

相关文章:

objective-c - 如何清除 MKMapView 缓存?

ios - iOS 多任务处理中的启动画面

postgresql - 如何找出 postgresql 用于执行类型转换的函数?

ios - 使用 KeyedDecodingContainer 解码具有随 secret 钥的对象

ios - Swift - 添加动画和声音 : Using animateWithTextures:

iphone - 取消自定义 MKAnnotationView 标注

c# - 映射具有不同属性的两个不同对象

c - 为什么将未使用的函数参数值转换为 void?

ios - Firebase 在 30 分钟内没有变化的情况下多次附加和分离 SnapshotListener 是否有成本?

ios - 将 UIView 输出到带有附加 View "inserted"的 UIImage 的最佳方法