Jay*_*ngh 5 fmdb ios hashable swift3
我正在使用sqlite文件从authorId获取diaryEntriesTeacher。当我打印变量authorId为nil时,它会生成authorId的以下对象:-
func applySelectQuery() {
checkDataBaseFile()
objFMDB = FMDatabase(path: fullPathOfDB)
objFMDB.open()
objFMDB.beginTransaction()
do {
let results = try objFMDB.executeQuery("select * from diaryEntriesTeacher", values: nil)
while results.next() {
let totalCount = results.resultDictionary
let authorId = totalCount?["authorId"]!
print("authorId",authorId)
}
}
catch {
print(error.localizedDescription)
}
print(fullPathOfDB)
self.objFMDB.commit()
self.objFMDB.close()
}
Run Code Online (Sandbox Code Playgroud)
这是您访问字典的方式 [AnyHashable : Any]
var dict : Dictionary = Dictionary<AnyHashable,Any>()
dict["name"] = "sandeep"
let myName : String = dict["name"] as? String ?? ""
Run Code Online (Sandbox Code Playgroud)
就你而言
let authorId = totalCount?["authorId"] as? String ?? ""
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7368 次 |
| 最近记录: |