Re: C struct and __unsafe_unretained
Re: C struct and __unsafe_unretained
- Subject: Re: C struct and __unsafe_unretained
- From: Alex Kac <email@hidden>
- Date: Sun, 30 Oct 2011 12:40:55 -0500
Its just making it clear that these are unretained. Make a #define to make it nice and clean like. But they are saying to make an objective C class mostly for people who do manual retain/releases in a struct so that its automatic.
Finally, NSDictionary doesn't support that - but CFDictionary does. We use that all the time. Its nice and neat. Just
insertedSections = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, 0, &kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(insertedSections, (void*)sectionIndex, section);
etc...
On Oct 30, 2011, at 12:32 PM, James Merkel wrote:
> The document on ARC talks about problematic C structs like:
>
> struct x { NSString *S; int X; } StaticArray[] = {
> @"foo", 42,
> @"bar, 97,
> ...
> };
>
> I use that pattern quite a bit in my code and haven't had any problems with it. These are basically constant strings that never change.
>
> With ARC, the compiler wants me to change the code to:
>
> struct x { __unsafe_unretained NSString *S; int X; }
>
> Aside from this looking really ugly, will the App store accept this in an application?
>
> The document on ARC says in order to do this task correctly, the code should be changed to a class. Ok, what class are they talking about?
>
> I don't see how the collection classes like NSDictionary or NSArray support this. Do they mean create your own collection class to do this?
>
> Thanks for any insight on this.
>
> Jim Merkel
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
Alex Kac - President and Founder
Web Information Solutions, Inc.
"Champions aren't made in the gyms. Champions are made from something they have deep inside of them - a desire, a dream, a vision. They have last-minute stamina, they have to be a little faster, they have to have the skill, and the will. But the will must be stronger than the skill."
-- Muhammad Ali
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden