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

x/mobile/bind: returning an empty string from go causes force unwrapping of nil on swift side #13087

Closed
scisci opened this issue Oct 28, 2015 · 1 comment

Comments

@scisci
Copy link

scisci commented Oct 28, 2015

If an exported go function with a string return type, returns an empty string. It actually ends up sending nil to the objective-c side.

However if one tries to read the string from the swift side it results in an error because it attempts to force unwrap a nil value. There also doesn't seem to be any way to test for nil before accessing the property.

This results in having to modify functions to return the string and also an error if that string is empty, and the client side first checks the error and can then read the string, which is none to convenient

I am using this direclty in Swift 2.0 and not using objective-c, so it could be an issue there.

@rakyll
Copy link
Contributor

rakyll commented Oct 28, 2015

/cc @hyangah

Returning a (NSString*)nil is a bug. We should never override the meaning of an empty string by converting into nil.

Once we return empty NSStrings, the Swift bug will be resolved.

@rakyll rakyll added this to the Unreleased milestone Oct 28, 2015
@golang golang locked and limited conversation to collaborators Nov 4, 2016
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
Fixes golang/go#13087

Change-Id: I9d7319d9ed3eee73e6479510911f796ab0607bd2
Reviewed-on: https://go-review.googlesource.com/16452
Reviewed-by: David Crawshaw <crawshaw@golang.org>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
Fixes golang/go#13087

Change-Id: I9d7319d9ed3eee73e6479510911f796ab0607bd2
Reviewed-on: https://go-review.googlesource.com/16452
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants