Reputation: 1974
I have this custom button:
class LocationButton: WKInterfaceButton {
func test() {
print("HERE")
}
}
And I try to use it in place of a WKInterfaceButton. In my Storyboard I have:
Custom Class
Class: LocationButton
Module: MyApp_WatchKit_Extension
And I have the following IBOutlet:
@IBOutlet weak var myButton: LocationButton!
@IBAction func myButtonClicked() {
myButton.test()
}
So when I click on this button it's supposed to call that test function. However, I get exc_bad_access
every time.
Is creating/using a custom class as a button even possible with WatchKit?
EDIT: I should note, that by debugging I can see that myButton is not nil. The outlet is working
Upvotes: 0
Views: 105
Reputation: 450
The documentation at https://developer.apple.com/documentation/watchkit/wkinterfacebutton says “Do not subclass or create instances of this class yourself.”
Seems like that would explain your error.
Upvotes: 1