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

Replace AnyObject with Any #3864

Merged
merged 2 commits into from
Mar 6, 2019
Merged

Replace AnyObject with Any #3864

merged 2 commits into from
Mar 6, 2019

Conversation

jjatie
Copy link
Collaborator

@jjatie jjatie commented Feb 24, 2019

This is in line with how Objc interfaces are now imported

This is in line with how Objc interfaces are now imported
@@ -245,9 +245,9 @@ public typealias NSUIGestureRecognizerState = UIGestureRecognizer.State
return _timestamp
}

init(target: AnyObject, selector: Selector)
init(target: Any, selector: Selector)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

despite the weird indent here by github, why we use Any and again cast to AnyObject later
I assume using AnyObject is fine

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to align with how ObjC APIs are imported into Swift. More info here: https://developer.apple.com/swift/blog/?id=39

We were only using AnyObject in the initializer because of weird objc interop.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh no. I'm using Dash and cannot even found Any type. this kind of information is not easily to be aware of in my daily work..

@liuxuan30
Copy link
Member

liuxuan30 commented Mar 5, 2019

@jjatie why would we change to Any here? I checked the doc:

You use AnyObject when you need the flexibility of an untyped object or when you use bridged Objective-C methods and properties that return an untyped result. AnyObject can be used as the concrete type for an instance of any class, class type, or class-only protocol.

so it seems the old AnyObject in this PR fits the scene. But using Any seems wilder, and unnecessary to me

@liuxuan30 liuxuan30 merged commit fe66742 into master Mar 6, 2019
@liuxuan30 liuxuan30 deleted the fix-objc-imports-anyobject branch March 6, 2019 01:21
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