drtimcooper / LatLongToTimezone

Lat/long to timezone mapper in Java. Does not require web services or data files - just pure Java or Swift.
MIT License
169 stars 33 forks source link

Objective-C compatibility #18

Closed alecvance closed 6 years ago

alecvance commented 7 years ago

Hi there!

To make the Swift class available from Objective-C all that's needed is to put @objc in front of the class definition, and make the TimezoneMapper class derive from NSObject. I'm using it now in this way. Thanks!

cheskapac commented 7 years ago

It is enough to make the TimezoneMapper class derive from NSObject.

lexar commented 6 years ago

Please, could you show the code for

for someone who is still a Swift newbie. It is very difficult to find clear information on this.

akirmse commented 6 years ago

NSObject was added awhile ago.

alecvance commented 5 years ago

Note that now in Xcode 10, when updating the project for Swift 4, it's necessary to include @objcMembers in the Swift file for this to be able to be imported into an Objective-C project. Otherwise you will get a method not found error when compiling.

This article shows the use of the @objcMembers prefix: https://medium.com/swift2go/swift-4-and-objc-warnings-b520083f411f

akirmse commented 5 years ago

I don't use Objective-C but feel free to send a PR.

On Tue, Dec 11, 2018 at 2:30 PM Alec Vance notifications@github.com wrote:

Note that now in Xcode 10, when updating the project for Swift 4, it's necessary to include @objcMembers in the Swift file for this to be able to be imported into an Objective-C project. Otherwise you will get a method not found error when compiling.

This article shows the use of the @objcMembers prefix: https://medium.com/swift2go/swift-4-and-objc-warnings-b520083f411f

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/drtimcooper/LatLongToTimezone/issues/18#issuecomment-446387548, or mute the thread https://github.com/notifications/unsubscribe-auth/ACKU8oLTTulpuj0z-HhDoh6y1ivHGJo9ks5u4DH1gaJpZM4M2Pg2 .