Automatic memory management of blocks #573
Labels
A-block2
Affects the `block2` crate
A-objc2
Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates
enhancement
New feature or request
It would be nice if we could get automatic memory management for blocks as well, instead of having to specify returned blocks as
*mut Block<dyn Fn()>
, and then converting those withRcBlock::copy
.If I'm reading the ARC spec right, it seems like blocks are actually autoreleased according to (mostly) the same rules as other Objective-C objects, and that we need to use
objc_retainAutoreleasedReturnValue
to access returned block pointers?A few examples of more complex memory-management:
-[NSBackgroundActivityScheduler scheduleWithBlock:]
, an example of a block taking a block as a parameter, which is kinda interesting.NSProgressPublishingHandler
, an example of a block returning a block.-[NSError userInfoValueProviderForDomain:]
, an example of a method returning a block.Also, should blocks be allowed in
Id
?The text was updated successfully, but these errors were encountered: