title: Present list of items in tableview from Realm database
body: <p>I am successfully downloading and printing data from Realm database. Here is my log:</p>
  
  <pre><code>Item(id: Optional(0), name: Optional("Item (0)"), descr: Optional("Description of item (0)"),
       icon: Optional("http://192.168.1.101:8080/api/items/0/icon.png"),
       url: Optional("http://192.168.1.101:8080/api/items/0")))
  </code></pre>
  
  <p>Now I have to assign those values on actual list and I am getting a clean sheet tableview. How to do it properly? I am using .xib as tablewViewCell. I am thankful for any tips.</p>
  
  <pre><code>class ItemRealm : Object {
      dynamic var id = 0
      dynamic var name = ""
      dynamic var desc = ""
      dynamic var icon = ""
  
  
      override class func primaryKey() -&gt; String? {
          return "id"
      }
  }
  
  
  class ViewController: UIViewController, UITableViewDataSource,    UISearchBarDelegate {
  
      @IBOutlet weak var searchBar: UISearchBar!
      @IBOutlet weak var tableView: UITableView!
  
  
      let realm = try! Realm()
      let results = try! Realm().objects(ItemRealm.self).sorted(byKeyPath: "id")
  
      let SERVER_URL = "http://192.168.1.101:8080/api/items"
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          Alamofire.request(SERVER_URL).responseJSON { response in
              let items = [Item].from(jsonArray: response.result.value as! [Gloss.JSON])
              print(items?[0] as Any)
  
              try! self.realm.write {
                  for item in items! {
                      let itemRealm = ItemRealm()
                      itemRealm.id = item.id!
                      itemRealm.name = item.name!
                      itemRealm.desc = item.descr!
                      itemRealm.icon = item.icon!
                      self.realm.add(itemRealm)
                  }
              }
              _ = self.realm.objects(ItemRealm.self)
             // print(items?[0] as Any)
          }
          // Do any additional setup after loading the view.
          tableView.register(UINib(nibName: "TableViewCell", bundle: nil), forCellReuseIdentifier: "TableViewCell")
      }
  
      // MARK: - UITableView data source
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return results.count
      }
  
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          let cell =  tableView.dequeueReusableCell(withIdentifier: "TableViewCell") as! TableViewCell
  
          var object: ItemRealm
          object = self.results[indexPath.row] as ItemRealm
  
          cell.item = object
  
          return cell
      }
  
  }
  </code></pre>