I make an app with Fiebase and Swift. Firstly, I can upload the URL and the name of the website. Then the name will be displayed on the cell. When I click the cell, I can see the website page. My problem is when I click every cell, it is the same website. But the URL I uploaded to Firebase is different. Code in the website page:
@IBOutlet weak var webView: UIWebView!
var web = [Web]()
var dataBaseRef: DatabaseReference! {
return Database.database().reference()
}
override func viewDidLoad() {
super.viewDidLoad()
dataBaseRef.child("webs").observe(.value, with: { (snapshot) in
var results = [Web]()
for user in snapshot.children {
let user = Web(snapshot: user as! DataSnapshot)
if user.webName != user.webUrl {
results.append(user)
let url = URL (string: user.webUrl as String)
let requestObj = URLRequest(url: url!)
self.webView.loadRequest(requestObj)
}
}
})
} Please help me to see what's the mistakes in the code. Thanks.