mirror of
https://github.com/tw93/Mole.git
synced 2026-02-12 07:04:00 +00:00
feat: Add VS Code launch/task configurations and refactor app icon and resource management.
This commit is contained in:
19
app/Extensions.swift
Normal file
19
app/Extensions.swift
Normal file
@@ -0,0 +1,19 @@
|
||||
import AppKit
|
||||
|
||||
extension Bundle {
|
||||
/// Loads an image from the bundle's resources by name.
|
||||
///
|
||||
/// This method attempts to load an image with the given name by trying
|
||||
/// common image file extensions in order: PNG, JPG, and ICNS.
|
||||
///
|
||||
/// - Parameter name: The name of the image resource without extension.
|
||||
/// - Returns: An NSImage if found, nil otherwise.
|
||||
///
|
||||
/// - Note: Supported formats: PNG, JPG, ICNS
|
||||
func image(forResource name: String) -> NSImage? {
|
||||
if let url = url(forResource: name, withExtension: "png") { return NSImage(contentsOf: url) }
|
||||
if let url = url(forResource: name, withExtension: "jpg") { return NSImage(contentsOf: url) }
|
||||
if let url = url(forResource: name, withExtension: "icns") { return NSImage(contentsOf: url) }
|
||||
return nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user