Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ecbfe9d

Browse files
committedJan 1, 2024
Fix potential memory/controller leak
1 parent 293d21b commit ecbfe9d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎Sources/FlickTypeKit/FlickTypeKit.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ public extension WKInterfaceController {
8888
internal func presentSystemInputController(_ invocation: TextInputInvocation) {
8989

9090
let flickTypeText = "⌨︎\tFlickType\n\tKeyboard"
91-
func completionWrapper(textInputControllerReturnedItems: [Any]?) {
92-
if let inputText = textInputControllerReturnedItems?.first as? String {
91+
// Ensure we only hold a weak reference to self here
92+
let completionWrapper: ([Any]?) -> Void = { [weak self] textInputControllerReturnedItems in
93+
if let self, let inputText = textInputControllerReturnedItems?.first as? String {
9394
if inputText == flickTypeText {
9495
return presentFlickTypeOrIntermediateController(invocation)
9596
}

0 commit comments

Comments
 (0)
Please sign in to comment.