Skip to content

Block arguments decorated w/ NS_NOESCAPE where appropriate#486

Merged
robbiehanson merged 1 commit into
yapstudios:masterfrom
Tundaware:no-escape-blocks
Apr 1, 2019
Merged

Block arguments decorated w/ NS_NOESCAPE where appropriate#486
robbiehanson merged 1 commit into
yapstudios:masterfrom
Tundaware:no-escape-blocks

Conversation

@gcox
Copy link
Copy Markdown
Contributor

@gcox gcox commented Feb 8, 2019

Resolves: #175

Objective-C closures are implicitly escaping, Swift closures are implicitly non-escaping 🤦‍♂️

For Swift projects using YapDB, if you create a func that has a closure argument, and that closure is then passed to a YapDB method (e.g. to synchronously enumerate something), you'll need to mark that closure as escaping, even though the method you're calling doesn't actually need it to be escaping.

Decorating the Objective-C block arguments w/ NS_NOESCAPE clarifies to the caller that no, the thing you're calling will not be hanging onto the closure you're passing it. Unless it's asynchronous, or the closure is actually stored (e.g. group blocks/sorting blocks/search handler blocks/etc), it doesn't need to be escaping.

@robbiehanson robbiehanson merged commit 832b308 into yapstudios:master Apr 1, 2019
@robbiehanson
Copy link
Copy Markdown
Contributor

Very cool. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants