Skip to content

Commit

Permalink
Changed UserActivityProvidable so the object is stored in the persist…
Browse files Browse the repository at this point in the history
…entIdentifier instead of the targetContentIdentifier. This allows all objects of the same type to have the same targetContentIdentifier and easily target a WindowGroup.
  • Loading branch information
ryanlintott committed Jul 24, 2023
1 parent dd743e9 commit d6f7e02
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Sources/ILikeToMoveIt/UserActivityProvidable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
Expand Down

0 comments on commit d6f7e02

Please sign in to comment.