简体   繁体   English

ARC 不允许目标 c 类型指针“CFDataRef”的隐式转换?

[英]implicit conversion of objective c type pointer 'CFDataRef' is disallowed with ARC?

I have a UDP type socket that I created last summer that worked fine, and still runs fine if I open the project file.我有一个去年夏天创建的 UDP 类型的套接字,它运行良好,如果我打开项目文件,它仍然可以正常运行。 However I have imported the.h/.m files into a new project, which does have ARC.但是,我已将 .h/.m 文件导入到一个新项目中,该项目确实有 ARC。

ARC does not like the following command(used in an if statement); ARC 不喜欢以下命令(在 if 语句中使用);

CFSocketSendData(WOLsocket, 
                   address,
                   Data,
                   0) < 0)

With the error:出现错误:

implicit conversion of objective c type pointer 'CFDataRef'(aka 'const struct__CFData' is disallowed with ARC目标 c 类型指针“CFDataRef”的隐式转换(又名“const struct__CFData”在 ARC 中是不允许的

The error is repeated, once for WOLsocket, and once for address错误重复出现,一次是WOLsocket,一次是address

where WOLsocket is created as follows; WOLsocket 的创建方式如下;

WOLsocket = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_DGRAM, IPPROTO_UDP, 0, NULL, NULL);
int desc = -1;
desc = CFSocketGetNative(WOLsocket);
int yes = 1;
setsockopt (desc, SOL_SOCKET, SO_BROADCAST, (char *)&yes, sizeof (yes))

(There is error checking code, this is the bare basics!) (有错误检查代码,这是最基本的!)

and address is created as so;地址是这样创建的;

memset(&addr, 0, sizeof(addr));
    addr.sin_len = sizeof(addr);
    addr.sin_family = AF_INET;
    addr.sin_port = htons(PORT); //port
    addr.sin_addr.s_addr = ad;
    address = [NSData dataWithBytes: &addr length: sizeof(addr)];

I am very confused as to why this is happening, all other ARC errors seemed to be solved by lossing the 'dealloc, release' statements!我很困惑为什么会这样,所有其他 ARC 错误似乎都可以通过丢失“dealloc,release”语句来解决!

So my question is, How do I get ARC to stop complaining about my use of CFData?所以我的问题是,如何让 ARC 停止抱怨我使用 CFData? (What modifications do I need to make?) (我需要做哪些修改?)

Thanks,谢谢,

Alex亚历克斯

Both the question and chosen answer to ARC and bridged cast should answer your question pretty well. ARC 和桥接演员的问题和选择的答案都应该很好地回答你的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从Objective-C指针到int *的隐式转换不允许使用ARC - Implicit Conversion from Objective-C Pointer to int * is Disallowed With ARC ARC不允许对Objective-C指针进行隐式转换 - Implicit conversion of an Objective-C pointer is disallowed with ARC ARC 不允许将 Objective-C 指针隐式转换为“void *” - implicit conversion of an Objective-C pointer to 'void *' is disallowed with ARC ARC不允许将Objective-C指针隐式转换为'const char *'? - Implicit conversion of an Objective-C pointer to 'const char *' is disallowed with ARC? ARC不允许将非目标C指针类型&#39;int *&#39;隐式转换为&#39;Bird *&#39; - Implicit conversion of a non-Objective-C pointer type 'int *' to 'Bird *' is disallowed with ARC ARC不允许将非Objective-C指针类型&#39;void *&#39;隐式转换为&#39;__unsafe_unretained id *&#39; - Implicit conversion of a non-Objective-C pointer type 'void *' to '__unsafe_unretained id *' is disallowed with ARC ARC不允许将非Object-C指针类型void *隐式转换为NSString * __ strong * - Implicit conversion of a non-Objective-C pointer type void* to NSString*__strong* is disallowed with ARC TPMultiLayoutViewController的ARC转换; ARC不允许将Objective-C指针隐式转换为“ const void *” - ARC conversion of TPMultiLayoutViewController; Implicit conversion of an Objective-C pointer to 'const void *' is disallowed with ARC 禁止使用arc将ios的间接指针隐式转换为目标c的id指针 - ios implicit conversion of an indirect pointer to an objective c pointer to id is disallowed with arc 错误:在NSTimer选择器中,ARC无法将Objective-C指针隐式转换为&#39;SEL _Nonnull&#39; - Error : Implicit conversion of an Objective-C pointer to 'SEL _Nonnull' is disallowed with ARC in Selector Of NSTimer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM