Created
March 2, 2021 03:41
-
-
Save djds23/aa720d66ad2af7e1d24d33ae29f49534 to your computer and use it in GitHub Desktop.
An SKAction that writes a value to a specified object.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension SKAction { | |
static func write<Root: AnyObject, Value>( | |
value: Value, | |
to keyPath: ReferenceWritableKeyPath<Root, Value>, | |
on object: Root | |
) -> SKAction { | |
SKAction.customAction(withDuration: 0) { [weak object] _, _ in | |
object?[keyPath: keyPath] = value | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment