i have server returns json of files , directories. structure looks like this:
{ "directory": { "file": ["2015-04-20t22:20:45+09:00", 130940928], "subdirectory": { "another file": ["2015-04-20t22:20:45+09:00", 130940928] } }, "rootfile": ["2015-04-20t22:20:45+09:00", 130940928] } i'm using alamofire along swiftyjson fetch data, , want convert json swift can manipulate — instance nsoutlineviewdatasource class.
i run 2 problems:
- how 1 loop through kind of json? way loop on
(name, content), , ifcontent[1].intnon-nil,namefile, else, it's folder , need perform new loop oncontent. - how 1 represent file hierarchy in swift?
for second point, made simple file class:
struct file { var name: string var path: nsurl } and can define directory array of files. however, file tree more complex can't predict how many levels of nesting array/dictionary need. there cocoa library use?
Comments
Post a Comment