• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: C struct and __unsafe_unretained
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C struct and __unsafe_unretained


  • Subject: Re: C struct and __unsafe_unretained
  • From: James Merkel <email@hidden>
  • Date: Sun, 30 Oct 2011 11:40:54 -0700

Ok thanks.  Not changing anything is the easiest and safest approach.

Jim Merkel

On Oct 30, 2011, at 10:52 AM, Dave Zarzycki wrote:

> On Oct 30, 2011, at 10:32 AM, 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.
>
> Is the above pattern in your code used with globals? (Probably.)
>
>> 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?
>
> Yes. "__unsafe_unretained" is public API, therefore the App store will accept it.
>
>> 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?
>
> That depends on the scenario. If the above struct is simply a global (and it probably is), then changing to a class would be more complicated than just using __unsafe_unretained. If the above struct is stored in malloc()ed memory, then switching to a class is the right thing to do.
>
> davez
>
>
>> 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
>

_______________________________________________

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

  • Follow-Ups:
    • Re: C struct and __unsafe_unretained
      • From: Thomas Davie <email@hidden>
References: 
 >C struct and __unsafe_unretained (From: James Merkel <email@hidden>)
 >Re: C struct and __unsafe_unretained (From: Dave Zarzycki <email@hidden>)

  • Prev by Date: Re: C struct and __unsafe_unretained
  • Next by Date: Re: C struct and __unsafe_unretained
  • Previous by thread: Re: C struct and __unsafe_unretained
  • Next by thread: Re: C struct and __unsafe_unretained
  • Index(es):
    • Date
    • Thread