• 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: Why is the ARC converter marking properties as weak?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is the ARC converter marking properties as weak?


  • Subject: Re: Why is the ARC converter marking properties as weak?
  • From: Matt Neuburg <email@hidden>
  • Date: Sat, 07 Jan 2012 09:24:36 -0800

On Wed, 28 Dec 2011 11:04:27 -0800, Jens Alfke <email@hidden> said:
>I'm experimentally converting a project to use ARC. The converter is doing some things that don't make sense to me. In particular, it's adding a "weak" modifier to the declarations of properties that are both read-only and not synthesized from an ivar. From my understanding of what "weak" means, it shouldn't apply to such a property at all.
>
>For example, in the header file:
>
>@property (readonly) NSArray* allViews;
>
>turns into
>
>@property (weak, readonly) NSArray* allViews;
>
>and in the .m file, there is an -allViews method whose implementation creates and returns a new NSArray object. The implementation was not changed.

It's illegal in ARC to have a property with *no* memory management policy. So the converter must supply something or we won't have ARC-legal code. I'm not saying that it's supplying the right policy, but it has to make up something because you didn't say anything explicit, and my guess is that since "assign" is the default in pre-ARC and since the converter is reluctant to assume you mean unsafe-unretained (which is the direct "assigned" synonym), it puts "weak" instead. (Also you might need to rethink the name "allViews", if it's outside ARC control and does its own memory management, but that's another issue.) m.

--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: ARC, Instruments and retain cycles
  • Next by Date: Re: ARC, Instruments and retain cycles
  • Previous by thread: Re: ARC, Instruments and retain cycles
  • Next by thread: Dylib and parent application symbol access
  • Index(es):
    • Date
    • Thread