Skip to content

fix: add @objc to touch methods in ViewModel examples#408

Open
yoyoyoyolol wants to merge 1 commit intorive-app:mainfrom
yoyoyoyolol:fix/viewmodel-touch-events
Open

fix: add @objc to touch methods in ViewModel examples#408
yoyoyoyolol wants to merge 1 commit intorive-app:mainfrom
yoyoyoyolol:fix/viewmodel-touch-events

Conversation

@yoyoyoyolol
Copy link

Summary

The touch methods in the ViewModel example classes (RiveSlider and RiveButton) were not being called because they lacked the @objc attribute.

Details

Since RiveStateMachineDelegate is an @objc protocol with optional methods, the runtime uses respondsToSelector: to check for implementation. In Swift, these methods must be explicitly marked with @objc (even if the class inherits from NSObject) to be visible to the Objective-C runtime for dynamic dispatch in this context.

Without this change, the slider and button in the "ViewModel Examples" section of the example app are non-functional.

Affected Files

  • Example-iOS/Source/Examples/ViewModel/RiveSlider.swift
  • Example-iOS/Source/Examples/ViewModel/RiveButton.swift

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.

1 participant