forked from AcaMate/AcaMate_iOS
37 lines
814 B
Swift
37 lines
814 B
Swift
//
|
|
// Key.swift
|
|
// AcaMate
|
|
//
|
|
// Created by Sean Kim on 11/26/24.
|
|
//
|
|
import Foundation
|
|
|
|
|
|
struct appKey: Codable {
|
|
let kakaoAppKey: String
|
|
}
|
|
|
|
|
|
|
|
struct KEY {
|
|
static func loadKey(for keyName: String) -> String? {
|
|
guard let path = Bundle.main.path(forResource: "KEY", ofType: "json") else {
|
|
// 파일을 찾을 수 없음
|
|
print("파일이 없습니다.")
|
|
return nil
|
|
}
|
|
do {
|
|
let data = try Data(contentsOf: URL(fileURLWithPath: path))
|
|
|
|
if let json = try JSONSerialization.jsonObject(with: data) as? [String: Any],
|
|
let value = json[keyName] as? String {
|
|
return value
|
|
}
|
|
} catch {
|
|
print("파싱 중 에러 발생")
|
|
}
|
|
return nil
|
|
}
|
|
}
|
|
|