Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block arguments decorated w/ NS_NOESCAPE where appropriate #486

Merged
merged 1 commit into from
Apr 1, 2019

Conversation

gcox
Copy link
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
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.

None yet

2 participants