• 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
__attribute((noescape)) doesn't prevent retain-cycle errors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

__attribute((noescape)) doesn't prevent retain-cycle errors


  • Subject: __attribute((noescape)) doesn't prevent retain-cycle errors
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 04 Aug 2015 13:09:00 -0700

Is __attribute((noescape)) — the Objective-C equivalent of Swift’s @noescape attribute — fully implemented yet (as of Xcode 7)? I’m trying to use it to avoid that pesky “capturing 'self' strongly in this block is likely to lead to a retain cycle” error.

I’ve got a method declared like so, with the ‘noescape’ attribute on the block parameter:

- (BOOL) addBytes: (const void*)bytes
           length: (size_t)length
         onOutput: (__attribute__((noescape)) void(^)(const void*,size_t))onOutput;

Then I call the method from another method like so:

    [_zipper addBytes: data.bytes length: data.length
             onOutput: ^(const void *bytes, size_t length) {
                 [_writer appendData: [[NSData alloc] initWithBytes ....

But I still get the retain-cycle error, even though the compiler/analyzer should be able to tell that no retain cycle is possible since it’s been promised that no one will hold onto a reference to the block.

I’ve tried this with Xcode 6.4 and Xode 7 beta 4 and get the same results.
Should I file a Radar or is this already known?

—Jens
 _______________________________________________
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: choose framework version at runtime
  • Next by Date: Xcode 6.4 on the Developer download site.
  • Previous by thread: way/add-on to create/edit class method definitions for .hpp/.cpp in “one-step"
  • Next by thread: Xcode 6.4 on the Developer download site.
  • Index(es):
    • Date
    • Thread