private func testcode() {
struct menuTree : Codable {
var title : String
var item : String
}
let menu1json = [menuTree(title:"1번메뉴", item:"1번아이템"),
menuTree(title:"2번메뉴", item:"1번아이템"),
menuTree(title:"2번메뉴", item:"2번아이템")]
var jsonString:String = ""
do {
let jsonData = try JSONEncoder().encode(menu1json)
jsonString = String(data: jsonData, encoding: .utf8)!
print(jsonString)
} catch {
print("Error in jsonData converting.")
}
if Path("~/menu1").isDirectory {
print("~/menu1 is already there")
} else {
do {
try Path("~/menu1").createDirectory()
print("~/menu1 directory has been created")
} catch {
print("cannot create ~/menu1 directory")
}
}
if Path("~/menu1/menu1.txt").exists {
print("file is already exist.")
} else {
try? Path("~/menu1/menu1.txt").createFile()
}
let menu1txt = TextFile(path: "~/menu1/menu1.txt")
try? jsonString |> menu1txt
}
'진행 프로젝트 > [진행] My tools.' 카테고리의 다른 글
kakao T crash (2) | 2019.01.18 |
---|---|
ibk onebank crash (0) | 2019.01.18 |
하스스톤 크러시 로그 (0) | 2019.01.18 |
오늘자 트러블 슈팅 (0) | 2019.01.08 |
Snapkit Error type - 1 (0) | 2019.01.02 |