尽管标记了文件 -fno-objc-arc,但 ARC 禁止在结构或联合中使用 Objective-C 对象

2023-03-24移动开发问题
1

本文介绍了尽管标记了文件 -fno-objc-arc,但 ARC 禁止在结构或联合中使用 Objective-C 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

ARC 禁止在结构或联合中使用 Objective-C 对象,尽管标记了文件 -fno-objc-arc?为什么会这样?

ARC forbids Objective-C objects in structs or unions despite marking the file -fno-objc-arc? Why is this so?

我假设如果你标记它 -fno-objc-arc 你没有这个限制.

I had the assumption that if you mark it -fno-objc-arc you don't have this restriction.

推荐答案

如果您收到此消息,请尝试 __unsafe_unretained.只有在结构中的对象未被保留时,它才是安全的.示例:如果您将 OpenFeint 与 ARC 一起使用,则 OFBragDelegateStrings 类会在结构中显示此错误.

If you got this message try __unsafe_unretained. It is only safe, if the objects in the struct are unretained. Example: If you use OpenFeint with ARC the Class OFBragDelegateStrings says this error in a struct.

typedef struct OFBragDelegateStrings
{
     NSString* prepopulatedText;
     NSString* originalMessage;
} OFBragDelegateStrings;

typedef struct OFBragDelegateStrings
{
     __unsafe_unretained NSString* prepopulatedText;
     __unsafe_unretained NSString* originalMessage;
} OFBragDelegateStrings;

这篇关于尽管标记了文件 -fno-objc-arc,但 ARC 禁止在结构或联合中使用 Objective-C 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

如何将 32 位 PNG 转换为 RGB565?
How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)...
2024-08-12 移动开发问题
21

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7