GithubHelp home page GithubHelp logo

Comments (4)

MacKentoch avatar MacKentoch commented on June 12, 2024 2

@RemcoB00 @Boris-Em Alright, I fixed my problem.

With Swift2+ even if you bridge nicely, you won't be able to have currentTimeOnClock method working (no error and never called).

I just removed @optionalfor this method only (BEMAnalogClockDelegate), I saw an error like No method declared with Objective-C selector (error was silenced because this method is optional in the delegate).

The fix is simple:

@objc(currentTimeOnClock:Hours:Minutes:Seconds:)
  func currentTimeOnClock(clock: BEMAnalogClockView!, hours: String!, minutes: String!, seconds: String!) {
    print("currentTimeOnClock called")
  }

Now it works even with Swift2+, if you:

  • bridge (that was already known)
  • add @objc(currentTimeOnClock:Hours:Minutes:Seconds:)

from bemanalogclock.

RemcoB00 avatar RemcoB00 commented on June 12, 2024

You can use Objective-C code in your Swift project by using a bridging header file (see the Apple website for more details). I use this project in my Swift app and it works great.

from bemanalogclock.

Boris-Em avatar Boris-Em commented on June 12, 2024

Thank you @RemcoB00 for confirming that it works with Swift.

from bemanalogclock.

MacKentoch avatar MacKentoch commented on June 12, 2024

@RemcoB00 @Boris-Em Did it work on a swift application?

It seems like currentTimeOnClock is never called in my test application in Swift.
Strange since other delegate methods like clockDidBeginLoading get called

Here is my code:

 class ViewController: UIViewController, BEMAnalogClockDelegate {

  @IBOutlet weak var clock: BEMAnalogClockView!

  override func viewDidLoad() {
    super.viewDidLoad()

    self.clock.delegate = self
    self.clock.realTime = true
    self.clock.currentTime = true
    self.clock.setTimeViaTouch = true
    self.clock.enableDigit = true

  }

  func clockDidBeginLoading(clock: BEMAnalogClockView!) {
    print("clockDidBeginLoading called")
  }

  func clockDidFinishLoading(clock: BEMAnalogClockView!) {
    print("clockDidFinishLoading called")
  }

  func currentTimeOnClock(clock: BEMAnalogClockView!, hours: String!, minutes: String!, seconds: String!) {
    print("currentTimeOnClock called")
  }

result:

clockDidBeginLoading called
clockDidFinishLoading called

from bemanalogclock.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.