嗨,大家好,我陷入了一個問題,無法找到解決方案。任何人都可以告訴我最新的問題,我剛開始學習迅速我想從我的數據火力數據庫,並打印在UITableViewCell的從UiTableViewCell中的單元格中的Firebase獲取沒有數據Swift 3
我創建了具有
類分類迅速文件:NSObject的{VAR 類別:字符串? }
我的viewController低於
import UIKit
import FirebaseDatabase
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
var categoryList = [Categories]()
var refHandle:UInt!
var ref:FIRDatabaseReference?
@IBOutlet weak var listOfCategories: UITableView!
@IBOutlet weak var menuBtn: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
ref = FIRDatabase.database().reference()
menuBtn.target = revealViewController()
menuBtn.action = #selector(SWRevealViewController.revealToggle(_:))
fetchCategories()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return categoryList.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .default, reuseIdentifier: "cell")
// Set cell content
cell.textLabel?.text = categoryList[indexPath.row].categories
return cell
}
func fetchCategories(){
refHandle = ref?.child("Categories").observe(.childAdded, with: { (snapshot) in
if let dictionary = snapshot.value as? [String: AnyObject] {
print(dictionary)
let categories = Categories()
categories.setValuesForKeys(dictionary)
self.categoryList.append(categories)
DispatchQueue.main.async
{
self.listOfCategories.reloadData()
}
}
})
}
}
我的數據庫
-Categories
-name
Bikes:"Bikes"
Cars:"Cars"
Cats:"Cats"
如果我打印(categorList)我不明白它的控制檯上也..下面是日誌
2017-04-06 06:09:50.531壁紙應用[1716] [Firebase/Analytics] [I-ACS023007] Firebase A 09:v.3700000開始 2017年4月6日06 nalytics 50.534壁紙應用[1716] [火力地堡/ Analytics(分析)] [I-ACS023008]啓用調試日誌記錄設置 以下應用參數:-FIRAnalyticsDebugEnabled(見 http://goo。 2017-04-06 06:09:50.565壁紙應用[1716] [Firebase/Analytics] [I-ACS003007]自動成功創建 Firebase Analytics應用委託代理。要禁用 代理,請在 Info.plist 2017-04-06 06:09:50.580壁紙應用中設置標誌FirebaseAppDelegateProxyEnabled爲NO [1716] [Firebase/Analytics] [I-ACS005000] AdSupport框架不是 目前已鏈接。某些功能將無法正常工作。瞭解更多 在http://goo。 gl/9vSsPb 2017-04-06 06:09:50.589壁紙應用[1716] [Firebase/Analytics] [I-ACS023012]啓用Firebase Analytics [「汽車」:汽車,「自行車」:自行車,「貓」:貓] 2017年4月6日06:09:52.565 壁紙應用[1716:28745] *終止應用程序由於未捕獲的異常 'NSUnknownKeyException',原因是: 「[ 的setValue:forUndefinedKey:]:此類不是關鍵值爲 編碼符合關鍵汽車。' *第一擲調用堆棧:(0的CoreFoundation 0x0000000104725d4b exceptionPreprocess + 171 1 libobjc.A.dylib
0x0000000103d6621e objc_exception_throw + 48 2的CoreFoundation
0x0000000104725c99 - [NSException提高] + 9 3基金會
0x00000001038749df - [NSObject的(的NSKeyValueCoding )的setValue:forKey:] + 291 4基金會0x00000001038d672f - [NSObject的(的NSKeyValueCoding)setValuesForKeysWithDictionary:] + 301 5壁紙應用0x00000001026fe886 _TFFC14Wallpapers_App14ViewController15fetchCategoriesFT_T_U_FCSo15FIRDataSnapshotT_ + 1126 6壁紙應用0x00000001026fed8c _TTRXFo_oCSo 15FIRDataSnapshot__XFdCb_dS_ + 60 7壁紙應用0x00000001027c85b0 63- [FIRDatabaseQuery observeEventType:withBlock:withCancelBlock:] _ block_invoke + 37 8
壁紙應用0x00000001027efeb3 __43- [FChildEventRegistration fireEvent:隊列:] _ block_invoke.68 + 88 9 libdispatch。dylib 0x0000000107470978 _dispatch_call_block_and_release + 12個10 libdispatch.dylib 0x000000010749a0cd _dispatch_client_callout + 8 11 libdispatch.dylib 0x000000010747a8a4 _dispatch_main_queue_callback_4CF + 406 12 的CoreFoundation 0x00000001046e9e49 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9 13的CoreFoundation 0x00000001046af37d __CFRunLoopRun + 2205 14的CoreFoundation 0x00000001046ae884 CFRunLoopRunSpecific + 420個15 GraphicsServices
0x0000000109439a6f GSEventRunModal + 161 16 UIKit
0x000000010525cc68 UIApplicationMain + 159 17壁紙App
0x0000000102701fcf main + 111 18 libdyld.dylib
0x00000001074e668d啓動+ 1)的libC++ abi.dylib:與類型NSException(LLDB的 未捕獲的異常)