Add capture lists to Objective-C blocks

Originator:stephan.michels
Number:rdar://17305330 Date Originated:13-Jun-2014 08:32 PM
Status:Open Resolved:
Product:OS X SDK Product Version:Mac OS X 10.9.3 (13D65)
Classification:Other Bug Reproducible:Always
 
Add something like Swift’s capture lists to Objective-C blocks to prevent 
instances to be capture by blocks and generate retain-cycles.

There exist “hacks” like @strongify and @weakify of libextobjc(http://github.com/jspahrsummers/libextobjc),
but this should be part of the compiler.

This could look like following code.

self.block = ^{
  @weak self; // <- break retain-cycle
  [self updateView];
};

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!