Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
Fix deprecation warning — use modern `NSWorkspace.shared.urlForApplic…
Browse files Browse the repository at this point in the history
…ation` instead of `NSWorkspace.shared.absolutePathForApplication`
  • Loading branch information
brentsimmons committed Feb 21, 2024
1 parent 9fa9d68 commit bc4e574
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Sources/RSCore/AppKit/UserApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ public final class UserApp {
path = bundleURL.path
}
else {
path = NSWorkspace.shared.absolutePathForApplication(withBundleIdentifier: bundleID)
path = pathForApplication(bundleIdentifier: bundleID)
}
if icon == nil, let path = path {
icon = NSWorkspace.shared.icon(forFile: path)
}
return
}

path = NSWorkspace.shared.absolutePathForApplication(withBundleIdentifier: bundleID)
path = pathForApplication(bundleIdentifier: bundleID)
if let path = path {
if icon == nil {
icon = NSWorkspace.shared.icon(forFile: path)
Expand Down Expand Up @@ -136,5 +136,14 @@ public final class UserApp {
return NSAppleEventDescriptor(runningApplication: runningApplication)
}
}
#endif

private extension UserApp {

func pathForApplication(bundleIdentifier: String) -> String? {

let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: bundleID)
return url?.path
}
}

#endif

0 comments on commit bc4e574

Please sign in to comment.