fixing commit
This commit is contained in:
parent
e1c4fdda63
commit
3fedfb3afe
@ -23,7 +23,7 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
let folderPath = Bundle.main.resourcePath! + "/JSON"
|
let folderPath = Bundle.main.resourcePath! + "/JSON"
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Life Cycle
|
// MARK: - Life Cycle
|
||||||
@ -31,10 +31,10 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
=======
|
|
||||||
var sectionsMap: [AnyHashable: Any] = [:]
|
var sectionsMap: [AnyHashable: Any] = [:]
|
||||||
|
|
||||||
override func viewDidLoad() {
|
func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
// Do any additional setup after loading the view.
|
// Do any additional setup after loading the view.
|
||||||
|
|
||||||
@ -51,16 +51,6 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
|
|||||||
}
|
}
|
||||||
sectionsMap[section] = array
|
sectionsMap[section] = array
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func getData(for indexPath: IndexPath) -> String? {
|
|
||||||
let sectionName = self.tableView(tableView, titleForHeaderInSection: indexPath.section)
|
|
||||||
let array = sectionsMap[sectionName!]! as! Array<Any>
|
|
||||||
let subPath = (array[indexPath.row] as! String)
|
|
||||||
let path = "\(folderPath)/\(sectionName!)/\(subPath)"
|
|
||||||
return try! String.init(contentsOfFile: path)
|
|
||||||
}
|
|
||||||
>>>>>>> develop
|
|
||||||
|
|
||||||
tableView.delegate = self
|
tableView.delegate = self
|
||||||
tableView.dataSource = self
|
tableView.dataSource = self
|
||||||
@ -70,11 +60,19 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
|
|||||||
ipTextField.text = "127.0.0.1:8181"
|
ipTextField.text = "127.0.0.1:8181"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getData(for indexPath: IndexPath) -> String? {
|
||||||
|
let sectionName = self.tableView(tableView, titleForHeaderInSection: indexPath.section)
|
||||||
|
let array = sectionsMap[sectionName!]! as! Array<Any>
|
||||||
|
let subPath = (array[indexPath.row] as! String)
|
||||||
|
let path = "\(folderPath)/\(sectionName!)/\(subPath)"
|
||||||
|
return try! String.init(contentsOfFile: path)
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Table View
|
// MARK: - Table View
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
||||||
return try? FileManager.default.contentsOfDirectory(atPath: folderPath)[section]
|
return try? FileManager.default.contentsOfDirectory(atPath: folderPath)[section]
|
||||||
}
|
}
|
||||||
@ -86,25 +84,24 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
|
|||||||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||||
|
|
||||||
return try! FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath)[section]).count
|
return try! FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath)[section]).count
|
||||||
=======
|
}
|
||||||
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
||||||
return (((sectionsMap as NSDictionary).allKeys[section]) as! String)
|
return (((sectionsMap as NSDictionary).allKeys[section]) as! String)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
func numberOfSections(in tableView: UITableView) -> Int {
|
||||||
return sectionsMap.count
|
return sectionsMap.count
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||||
let sectionName = self.tableView(tableView, titleForHeaderInSection: section)
|
let sectionName = self.tableView(tableView, titleForHeaderInSection: section)
|
||||||
let array = sectionsMap.arrayForKey(sectionName!)
|
let array = sectionsMap.arrayForKey(sectionName!)
|
||||||
return array.count
|
return array.count
|
||||||
>>>>>>> develop
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
|
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
|
||||||
|
|
||||||
let name = try? FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath)[indexPath.section])[indexPath.row]
|
let name = try? FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath)[indexPath.section])[indexPath.row]
|
||||||
@ -125,14 +122,15 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
|
|||||||
button.backgroundColor = .red
|
button.backgroundColor = .red
|
||||||
button.tag = section // why not... ``\__(~_~)__/``
|
button.tag = section // why not... ``\__(~_~)__/``
|
||||||
button.addTarget(self, action: #selector(requestJSON), for: .touchUpInside)
|
button.addTarget(self, action: #selector(requestJSON), for: .touchUpInside)
|
||||||
=======
|
}
|
||||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
||||||
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||||
|
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
|
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
|
||||||
|
|
||||||
let sectionName = self.tableView(tableView, titleForHeaderInSection: indexPath.section)
|
let sectionName = self.tableView(tableView, titleForHeaderInSection: indexPath.section)
|
||||||
let array = sectionsMap[sectionName!]! as! Array<Any>
|
let array = sectionsMap[sectionName!]! as! Array<Any>
|
||||||
cell.textLabel?.text = (array[indexPath.row] as! String)
|
cell.textLabel?.text = (array[indexPath.row] as! String)
|
||||||
>>>>>>> develop
|
|
||||||
|
|
||||||
return button
|
return button
|
||||||
}
|
}
|
||||||
@ -142,7 +140,6 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Methods
|
// MARK: - Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -173,8 +170,9 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
=======
|
|
||||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||||
|
|
||||||
UIPasteboard.general.string = getData(for: indexPath)
|
UIPasteboard.general.string = getData(for: indexPath)
|
||||||
|
|
||||||
let label = UILabel(frame: .zero)
|
let label = UILabel(frame: .zero)
|
||||||
@ -187,12 +185,15 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa
|
|||||||
view.superview!.addSubview(label)
|
view.superview!.addSubview(label)
|
||||||
label.centerXAnchor.constraint(equalTo: view.superview!.centerXAnchor).isActive = true
|
label.centerXAnchor.constraint(equalTo: view.superview!.centerXAnchor).isActive = true
|
||||||
label.centerYAnchor.constraint(equalTo: view.superview!.centerYAnchor).isActive = true
|
label.centerYAnchor.constraint(equalTo: view.superview!.centerYAnchor).isActive = true
|
||||||
|
|
||||||
UIView.animate(withDuration: 2, animations: {
|
UIView.animate(withDuration: 2, animations: {
|
||||||
label.alpha = 0
|
label.alpha = 0
|
||||||
}) { (completed) in
|
}) { completed in
|
||||||
label.removeFromSuperview()
|
label.removeFromSuperview()
|
||||||
}
|
}
|
||||||
>>>>>>> develop
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,15 +204,15 @@ extension MasterViewController: UIDragInteractionDelegate {
|
|||||||
|
|
||||||
let location = session.location(in: tableView)
|
let location = session.location(in: tableView)
|
||||||
let indexPath = tableView.indexPathForRow(at: location)
|
let indexPath = tableView.indexPathForRow(at: location)
|
||||||
<<<<<<< HEAD
|
|
||||||
let sectionName = try! FileManager.default.contentsOfDirectory(atPath: folderPath)[indexPath!.section]
|
let sectionName = try! FileManager.default.contentsOfDirectory(atPath: folderPath)[indexPath!.section]
|
||||||
let path = try! folderPath + "/" + sectionName + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + sectionName)[indexPath!.row]
|
let path = try! folderPath + "/" + sectionName + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + sectionName)[indexPath!.row]
|
||||||
let content = try! String(contentsOfFile: path)
|
let content = try! String(contentsOfFile: path)
|
||||||
let provider = NSItemProvider(object: content as NSString)
|
let provider = NSItemProvider(object: content as NSString)
|
||||||
=======
|
|
||||||
let content = getData(for: indexPath!)
|
let content = getData(for: indexPath!)
|
||||||
let provider = NSItemProvider(object: content! as NSString)
|
let provider = NSItemProvider(object: content! as NSString)
|
||||||
>>>>>>> develop
|
|
||||||
let item = UIDragItem(itemProvider: provider)
|
let item = UIDragItem(itemProvider: provider)
|
||||||
|
|
||||||
return [item]
|
return [item]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user