mirror of
https://github.com/neon443/NearFuture.git
synced 2026-03-11 06:49:12 +00:00
37 lines
874 B
Swift
37 lines
874 B
Swift
//
|
|
// SymbolsLoader.swift
|
|
// NearFuture
|
|
//
|
|
// Created by neon443 on 14/06/2025.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
class SymbolsLoader: ObservableObject {
|
|
@Published var allSymbols: [String] = []
|
|
|
|
init() {
|
|
self.allSymbols = getAllSymbols()
|
|
}
|
|
|
|
func getSymbols(_ searched: String) -> [String] {
|
|
if searched.isEmpty {
|
|
return allSymbols
|
|
} else {
|
|
return allSymbols.filter() { $0.localizedCaseInsensitiveContains(searched) }
|
|
}
|
|
}
|
|
|
|
func getAllSymbols() -> [String] {
|
|
var allSymbols = [String]()
|
|
if let bundle = Bundle(identifier: "com.apple.CoreGlyphs"),
|
|
let resPath = bundle.path(forResource: "name_availability", ofType: "plist"),
|
|
let plist = try? NSDictionary(contentsOf: URL(fileURLWithPath: resPath), error: ()),
|
|
let plistSymbols = plist["symbols"] as? [String: String]
|
|
{
|
|
allSymbols = Array(plistSymbols.keys)
|
|
}
|
|
return allSymbols
|
|
}
|
|
}
|