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

Using takeRetainedValue is a bad idea and leads to crashes (iOS 15) #41

Open
houmie opened this issue Jun 15, 2022 · 0 comments
Open

Using takeRetainedValue is a bad idea and leads to crashes (iOS 15) #41

houmie opened this issue Jun 15, 2022 · 0 comments

Comments

@houmie
Copy link

houmie commented Jun 15, 2022

I start getting exception errors on the second line, even though I'm passing clearly "facebook.com" to it.

let cfhost = CFHostCreateWithName(nil, host as CFString).takeRetainedValue()
let status = CFHostStartInfoResolution(cfhost, .addresses, &streamError)

takeRetainedValue is saying that I'm responsible for keeping that string variable in scope. But that value could be getting deallocated while it's still being used, when the app goes in background mode for example.

It could be nil by the time it gets to line two. The solution could be maybe to hold onto it as a class variable instead.

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

1 participant