From d6f7e02ad4b03de4ee52ceab8edbddcc5b49314b Mon Sep 17 00:00:00 2001 From: Ryan Lintott Date: Sun, 23 Jul 2023 23:45:55 -0400 Subject: [PATCH] Changed UserActivityProvidable so the object is stored in the persistentIdentifier instead of the targetContentIdentifier. This allows all objects of the same type to have the same targetContentIdentifier and easily target a WindowGroup. --- Sources/ILikeToMoveIt/UserActivityProvidable.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/ILikeToMoveIt/UserActivityProvidable.swift b/Sources/ILikeToMoveIt/UserActivityProvidable.swift index 6ceb23e..b87fd76 100644 --- a/Sources/ILikeToMoveIt/UserActivityProvidable.swift +++ b/Sources/ILikeToMoveIt/UserActivityProvidable.swift @@ -21,7 +21,7 @@ public extension UserActivityProvidable { init?(activity: NSUserActivity) { guard activity.activityType == Self.activityType else { return nil } guard - let data = activity.targetContentIdentifier?.data(using: .utf8), + let data = activity.persistentIdentifier?.data(using: .utf8), let item = try? JSONDecoder().decode(Self.self, from: data) else { return nil @@ -36,7 +36,9 @@ public extension UserActivityProvidable { else { return nil } let activity = NSUserActivity(activityType: Self.activityType) let string = String(data: data, encoding: .utf8) - activity.targetContentIdentifier = string + /// Stores the entire object in the persistent identifier + activity.persistentIdentifier = string + activity.targetContentIdentifier = Self.activityType return activity } }