Skip to content
Permalink
Browse files

Some more shit

  • Loading branch information...
HeyItsJohnny HeyItsJohnny
HeyItsJohnny authored and HeyItsJohnny committed Apr 1, 2018
1 parent 5fe2b6d commit 47b828131cdd7ca841adeb2896e511556c401d54
@@ -10,7 +10,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "RestAPIEngine.swift"
timestampString = "544302039.1565239"
timestampString = "544310242.670661"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "14"
@@ -154,7 +154,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ProjectCondo-Beta_V2/HousesTableViewController.swift"
timestampString = "544302039.156721"
timestampString = "544310242.671104"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "11"
@@ -425,11 +425,6 @@
</connections>
</tableView>
<navigationItem key="navigationItem" id="pzE-bf-ixC">
<barButtonItem key="leftBarButtonItem" title="Item" id="ANy-8H-NFb">
<connections>
<action selector="test:" destination="aM3-IF-PsN" id="zIJ-t7-xx2"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" systemItem="add" id="7oR-Eb-VNS">
<connections>
<action selector="OpenCreateHouse:" destination="aM3-IF-PsN" id="tSm-HZ-RG6"/>
@@ -14,7 +14,7 @@ private let kSessionTokenKey = "SessionToken"
private let DbServiceName = "/mongodb/_table"
private let ContainerName = "profile_images"

private let kRestHome = "mongodb/_table/home"
private let kRestHome = "/mongodb/_table/home"
private let kRestHomeUserRelationship = "/mongodb/_table/home_user_relationship"

protocol HomesDelegate {
@@ -27,6 +27,7 @@ class DataAccess {
fileprivate var restClient = RESTAPIEngine()

func getHomes(_ group:HomeRecord?, email: String, resultDelegate: HomesDelegate) {
print("GET HOMES")
getHomesAll(email, resultDelegate: resultDelegate)
}

@@ -36,11 +37,14 @@ class DataAccess {

fileprivate func getHomesAll(_ userEmail: String, resultDelegate: HomesDelegate) {
let queryParams: [String: AnyObject] = ["filter": "email=\(userEmail)" as AnyObject]
print("START GET ALL HOMES")
restClient.callRestService(kRestHome, method: .GET, queryParams: queryParams as! [String : String], body: nil) { restResult in
if restResult.bIsSuccess {
print("start bISSuccess")
var homes = [HomeRecord]()
if let homesArray = restResult.json?["resource"] as? JSONArray {
for homeJSON in homesArray {
print("appending...")
homes.append(HomeRecord(json:homeJSON))
}
}
@@ -12,23 +12,15 @@ class HousesTableViewController: UITableViewController, HomesDelegate{

fileprivate var homeArray2: [String:String] = [:]
fileprivate var houseArrayTemp: [String]!
fileprivate var homesByHome = [String: [HomeRecord]]()
fileprivate var currentHomes:HomeRecord? = nil
fileprivate let dataAccess = DataAccess.sharedInstance
fileprivate var homes = [HomeRecord]()

@IBAction func OpenCreateHouse(_ sender: Any) {
showCreateHouseViewController();
}
@IBAction func test(_ sender: Any) {
getHouseDataPerUser()
data.removeAll()
for (key,value) in self.homeArray2 {
print("Key: " + key + " Name:" + value)
data.append(value)
}
tableView.reloadData()
}


override func viewDidLoad() {
super.viewDidLoad()
data.removeAll()
@@ -53,15 +45,20 @@ class HousesTableViewController: UITableViewController, HomesDelegate{
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.count
return homes.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "homeCell")! //1.
var homeName = "(no-name)"
print("Start: NOTHING")
if let home = homeForIndexPath(indexPath) {

homeName = home.houseName
print("Home Name: " + homeName)
}

let text = data[indexPath.row] //2.
cell.textLabel?.text = text //3.
cell.textLabel?.text = homeName

return cell //4.
}

@@ -72,14 +69,15 @@ class HousesTableViewController: UITableViewController, HomesDelegate{
dataAccess.getHomes(currentHomes, email: curremail, resultDelegate: self)
}

fileprivate func homeForIndexPath(_ indexPath:IndexPath) -> HomeRecord? {
var home:HomeRecord? = nil
home = homes[(indexPath as NSIndexPath).row]
return home
}

//Homes Delegate
func setHomes(_ homes: [HomeRecord]) {
self.homes = homes

/*for home in homes {
//let homename = home.houseName
//let firstChar = String(describing: homename?.prefix(1))
}*/
tableView.setContentOffset(CGPoint.zero, animated: true)
tableView.reloadData()
}
@@ -420,6 +420,7 @@ final class RESTAPIEngine {
}
}
default:
print(callResult)
resultClosure(callResult)
}
})

0 comments on commit 47b8281

Please sign in to comment.
You can’t perform that action at this time.