1
我有一個函數從我的firebase數據庫中返回一個數組。問題是它總是在數據庫中返回值之前打印捕捉(數字,其中項目位於所以例如0),因此,例如,它將打印[snap(0)teamname]如何從數據庫中的項目之前刪除「snap」
我將如何擺脫這snap(num)在值的開始處。也許有某種框架從數組中刪除某些短語?讓我知道這裏是我的代碼和數據庫。
import UIKit
import Foundation
import Firebase
class CSGOView: UIViewController, UITableViewDelegate, UITableViewDataSource{
var teams: [String] = []
var times: [String] = []
@IBOutlet weak var tableViewTwo: UITableView!
let teamsRef = FIRDatabase.database().reference(fromURL: "can't have this info sorry, basically it goes straight to Teams in the database")
override func viewDidLoad() {
super.viewDidLoad()
getTeamsAndTimes()
}
func getTeamsAndTimes() {
teamsRef.observeSingleEvent(of: .value, with: { (snapshot) in
let d = snapshot.children.allObjects
print(d)
for child in snapshot.children {
print(child)
}
}) { (error) in
print(error.localizedDescription)
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell: UITableViewCell? = nil
return cell!
}
}
這裏是顯示數據庫的圖像,以及它的佈局。
,這裏是控制檯輸出
[Snap (0) FaZe Clan, Snap (1) Natus Vincere, Snap (2) Natus Vincere, Snap (3) FaZe Clan, Snap (4) HellRaisers, Snap (5) G2 Esports, Snap (6) G2 Esports, Snap (7) HellRaisers, Snap (8) NRG Esports, Snap (9) Counter Logic Gaming, Snap (10) Counter Logic Gaming, Snap (11) NRG Esports, Snap (12) OpTic Gaming, Snap (13) Rush, Snap (14) Rush, Snap (15) OpTic Gaming]
Snap (0) FaZe Clan
Snap (1) Natus Vincere
Snap (2) Natus Vincere
Snap (3) FaZe Clan
Snap (4) HellRaisers
Snap (5) G2 Esports
Snap (6) G2 Esports
Snap (7) HellRaisers
Snap (8) NRG Esports
Snap (9) Counter Logic Gaming
Snap (10) Counter Logic Gaming
Snap (11) NRG Esports
Snap (12) OpTic Gaming
Snap (13) Rush
Snap (14) Rush
Snap (15) OpTic Gaming
OH MY GOODNESS。你是最棒的傢伙,一直都在努力工作。謝謝你甚至向我展示瞭如何更新單元格以及我真正感激它的所有內容。如果我可能會問,你是如何擅長編程的?你只是爲一個快速的應用程序製作公司嗎?你是否閱讀過許多應用程序?任何對我的推薦?感謝您的答案,它完美的工作@Nirav D –
@DevinTripp歡迎隊友:)伴侶,如果你閱讀蘋果swift文檔,那麼你將得到足夠的知識開發應用程序在迅速朗,沒有大的任務:) –
你告訴我你讀所有來自蘋果的文檔,這是您使用的唯一資源。我希望這很容易。我不明白很多的語法,所以對我來說有點困難。我接受了答案,我非常感謝D! –