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
}
'HJH IT Logs' 카테고리의 다른 글
밀위키 (0) | 2019.01.18 |
---|---|
아이폰별 화면 해상도 (0) | 2019.01.18 |
어디에나 띄우는 로딩중 동그라미 + 딜레이 주는 방법 (0) | 2019.01.17 |
toss (1) | 2019.01.17 |
rm -rf / 방지 (0) | 2019.01.16 |
최근댓글