Open
Description
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 with RcBlock::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.