简体   繁体   English

ARC 不允许将 Objective-C 指针隐式转换为“void *”

[英]implicit conversion of an Objective-C pointer to 'void *' is disallowed with ARC

What does this mean and what alternative do I have?这是什么意思,我有什么选择?

implicit conversion of an Objective-C pointer to 'void *' is disallowed with ARC ARC 不允许将 Objective-C 指针隐式转换为“void *”

I am porting an Xcode3 project to iOS5 which uses AudioSessionInitialize like this我正在将一个 Xcode3 项目移植到 iOS5,它像这样使用 AudioSessionInitialize

AudioSessionInitialize(NULL, NULL, NULL, self);

where self here is a ViewController.这里的self是一个 ViewController。

You should use __bridge cast for it.你应该使用 __bridge cast 。

AudioSessionInitialize(NULL, NULL, NULL, (__bridge void *)self);

You can't do implicit casts to void* anymore, AudioSessionInitialize(NULL, NULL, NULL, objc_unretainedPointer(self));你不能再对void*进行隐式转换了, AudioSessionInitialize(NULL, NULL, NULL, objc_unretainedPointer(self)); should do the trick.应该做的伎俩。

EDIT: Historical point, the answer above was from before the __bridge casts were finalized.编辑:历史观点,上面的答案来自__bridge演员表最终确定之前。 In modern code the correct answer is that provided by @KazukiSakamoto, AudioSessionInitialize(NULL, NULL, NULL, (__bridge void*)self);在现代代码中,正确答案是@KazukiSakamoto, AudioSessionInitialize(NULL, NULL, NULL, (__bridge void*)self);

暂无
暂无

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

相关问题 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-sqlite3不允许将Objective-C指针隐式转换为'void *' - implicit conversion of an Objective-C pointer to 'void *' is disallowed with ARC - sqlite3 ARC不允许将Objective-C指针隐式转换为'const char *'? - Implicit conversion of an Objective-C pointer to 'const char *' is disallowed with ARC? 从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 *'隐式转换为'__unsafe_unretained id *' - 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 错误:在NSTimer选择器中,ARC无法将Objective-C指针隐式转换为'SEL _Nonnull' - Error : Implicit conversion of an Objective-C pointer to 'SEL _Nonnull' is disallowed with ARC in Selector Of NSTimer 将属性移动到.h文件后,ARC不允许将Objective-C指针隐式转换为“ int *” - Implicit conversion of an Objective-C pointer to 'int *' is disallowed with ARC after move property to .h file 在 Objective-C 中,arc 不允许将 int 隐式转换为 NSString - implicit conversion of int to NSString is disallowed with arc in Objective-C
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM