for result in groups{
let tmp = result.subject
print("groups subject is \(tmp)")
}
我得到groups subject is MyGroupsData
我想在tableView cellForRowAtIndex
var channel : myEntity?
groupsData = groups[indexPath.row] as? myEntity
dataSubject = groupsData!.subject
print("groups subject is \(dataSubject)")
显示groups subject is nil
原因:fatal error: unexpectedly found nil while unwrapping an Optional value
如何解决?
答案 0 :(得分:0)
尝试使用
if let subject = groupsData?.subject {
dataSubject = subject
}
问题是groupsData是nil而你正试图获得一个不存在的值。