Good morning everybody,
I'm having a table view which display objects saved from 2 different classes. Im going to combine these result into one array to display in tableView. Here is my code:
import UIKit
import RealmSwift
class BookmarksVC: UIViewController,UITableViewDelegate,UITableViewDataSource {
var articleList: Results<DynamicObject>!
var documentList: Results<DynamicObject>!
var list = [Any]()
var article: Any!
var searchBar:UISearchBar = UISearchBar(frame: CGRect(x: 0, y: 0, width: 280, height: 20))
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(UINib(nibName: "BookmarkCell", bundle: nil), forCellReuseIdentifier: "bookmarkCell")
tableView.delegate = self
tableView.dataSource = self
drawNavBarUI(navigationItem: self.navigationItem, searchBar: searchBar)
loadDataAndUpdateUI()
}
func loadDataAndUpdateUI() {
articleList = realm.dynamicObjects(NewsArticle.className())
documentList = realm.dynamicObjects(Documents.className())
list.append(articleList)
list.append(documentList)
tableView.setEditing(false, animated: true)
tableView.reloadData()
}
But the result was:
it lead to the tableview just displayed only 2 cell. I tried to use append(ContentsOf:) but Xcode forced it back to append(). This is my first time using Realm, so i might not have deep understanding about it. So anyone can help me to solve this problem?. Thank you guys for reading and sorry for my bad English.
