__attribute((noescape)) doesn't prevent retain-cycle errors
__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