1
votes

Sorry I'm not very good at explaining this stuff. Basically I have the function below to handle remote control events.

UIApplication.sharedApplication().beginReceivingRemoteControlEvents()
override func remoteControlReceivedWithEvent(event: UIEvent) {
    if event.type == UIEventType.RemoteControl {
        if event.subtype == UIEventSubtype.RemoteControlPlay {
            stream.play()
        } else if event.subtype == UIEventSubtype.RemoteControlPause {
            stream.stop()
        } else if event.subtype == UIEventSubtype.RemoteControlTogglePlayPause {
            toggle()
        }
    }
}

Essentially, when I use the term "override" (shown above), I get the error

"Method does not override any method from its superclass.

If I leave out the "override", I get the error:

"Method 'remoteControlReceivedWithEvent' with Objective-C selector 'remoteControlReceivedWithEvent:' conflicts with method "remoteControlReceivedWithEvent" from superclass "UIResponder" with the same Objective-C selector.

I'm pretty new to all of this so I don't really understand what the issue is. Can someone please explain how to remedy this issue? Let me know if you need some more code or something.

Is there more code I have to use to set this up?

1

1 Answers

6
votes

There is a mismatch of UIResponder method signature and your function implementation. UIResponder has optional Event as following: func remoteControlReceibedWithEvent(_ event: UIEvent?)

So it can not override as there is no function with non-optional argument, but if you remove override it will conflict with ObjC implementation, as selector names are the same.