Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARC forbids Objective-C objects in structs or unions despite marking the file -fno-objc-arc

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

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

like image 457
Zsolt Avatar asked Nov 11 '11 11:11

Zsolt


2 Answers

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;

to

typedef struct OFBragDelegateStrings
{
     __unsafe_unretained NSString* prepopulatedText;
     __unsafe_unretained NSString* originalMessage;
} OFBragDelegateStrings;
like image 123
zeiteisen Avatar answered Nov 01 '22 21:11

zeiteisen


Rather than using a struct, you can create an Objective-C class to manage the data instead.

like image 30
János Avatar answered Nov 01 '22 23:11

János