mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-10 09:39:58 +00:00
Improve optional checking in native selector
This commit is contained in:
20
app/NativeMacReceiverSelector/InitDataProvider.swift
Normal file
20
app/NativeMacReceiverSelector/InitDataProvider.swift
Normal file
@@ -0,0 +1,20 @@
|
||||
import Cocoa
|
||||
|
||||
class InitDataProvider {
|
||||
static let shared = InitDataProvider()
|
||||
|
||||
let data: InitData
|
||||
|
||||
private init() {
|
||||
if CommandLine.argc < 2 {
|
||||
fatalError("Missing init data")
|
||||
}
|
||||
|
||||
if let input = CommandLine.arguments[1].data(using: .utf8)
|
||||
, let parsed = try? JSONDecoder().decode(InitData.self, from: input) {
|
||||
self.data = parsed
|
||||
} else {
|
||||
fatalError("Failed to convert and parse init data")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user