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

didTouchCosmos closure can capture self #6

Closed
agordeev opened this issue Nov 5, 2015 · 3 comments
Closed

didTouchCosmos closure can capture self #6

agordeev opened this issue Nov 5, 2015 · 3 comments

Comments

@agordeev
Copy link

agordeev commented Nov 5, 2015

I'd be safer to change this

cosmosView.didTouchCosmos = { rating in }

to this

cosmosView.didTouchCosmos = { [unowned self] rating in }

in case if we'd use this code within view controller. Otherwise didTouchCosmos closure captures a reference to self and retain cycle is created.

@evgenyneu
Copy link
Owner

Hi, yes, I agree, which part of code are you referring to?

@agordeev
Copy link
Author

agordeev commented Nov 6, 2015

README

@evgenyneu
Copy link
Owner

I would not put the capture list to this example in the readme, which currently is:

// Receive user input
cosmosView.didTouchCosmos = { rating in }

In my opinion, putting capture list will make the example a little bit complicated and move the focus away from its main purpose. Remember, we are not teaching people Swift language here, but rather explaining how to use the library. Note that in some situation people will not need to use capture list at all, or they will need to use [weak self] instead of [unowned self]. Explaining all those nuances in this readme is a bit out of the scope of this document and could be distractive. Thank you for your feedback.

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

No branches or pull requests

2 participants