-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
40 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,45 @@ | ||
import UIKit | ||
import RealmSwift | ||
|
||
class AccountsViewController: UIViewController { | ||
class AccountsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { | ||
|
||
@IBOutlet weak var tableView: UITableView! | ||
var accountsTable : Results<AccountDTO>? | ||
var realm : Realm! | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
// Do any additional setup after loading the view, typically from a nib. | ||
|
||
self.realm = try! Realm() | ||
self.accountsTable = self.realm.objects(AccountDTO.self) | ||
} | ||
|
||
override func didReceiveMemoryWarning() { | ||
super.didReceiveMemoryWarning() | ||
// Dispose of any resources that can be recreated. | ||
} | ||
|
||
override func viewWillAppear(_ animated: Bool) { | ||
self.accountsTable = realm.objects(AccountDTO.self) | ||
tableView.reloadData() | ||
} | ||
|
||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
//if let table = self.expensesTable { | ||
// return table.count | ||
//} | ||
return (self.accountsTable?.count)! | ||
} | ||
|
||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
let cell = tableView.dequeueReusableCell(withIdentifier: "accountCell", for: indexPath) as! AccountCell | ||
|
||
cell.accountLabel.text = self.accountsTable?[indexPath.row].name | ||
cell.accountImage.image = UIImage(named: "food_icon") //accountsTable[indexPath.row].image | ||
|
||
return cell | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters