Skip to content

Instantly share code, notes, and snippets.

View KeanuPang's full-sized avatar
🙆
Avoid Boring People

Keanu Pang KeanuPang

🙆
Avoid Boring People
View GitHub Profile
@KeanuPang
KeanuPang / load.swift
Created May 6, 2021 03:56
用 fileDescriptor 來讀取 Localizable.strings 檔案
func loadLocalizableStringsFile() -> [String: String]? {
guard let localizePath = Bundle.main.path(forResource: "Localizable", ofType: "strings") else { return nil }
let fileHandle = FileHandle(fileDescriptor: open(localizePath, O_RDONLY))
let data = fileHandle.readDataToEndOfFile()
fileHandle.closeFile()
var format = PropertyListSerialization.PropertyListFormat.binary
return try? PropertyListSerialization.propertyList(from: data, options: .mutableContainers, format: &format) as? [String: String]
}