我有以下两个变量,并按如下所述提取请求,
var histBooks = [String]()
var bookDescs = [String]()
let request = NSFetchRequest<NSFetchRequestResult>(entityName: "BookDetail")
request.returnsObjectsAsFaults = false
do
{
let results = try context.fetch(request)
if results.count > 0
{
for result in results as! [NSManagedObject]
{
if let bookDesc = result.value(forKey: "bookTitle") as? String
{
bookDescs.append(bookDesc)
}
}
catch{}
}
我使用for loop
将这些变量附加为
histBooks.append(bookDescs[i])
现在在cellForRowAtIndexPath
处,我想使用fetchedResultsController
来获取数据,由于数组中的数据,我无法弄清。我可以显示以下数据
let cell = tableView.dequeueReusableCell(withIdentifier: "booksTableViewCell") as! BooksTableViewCell
let bookDetail = fetchedResultsController.fetchedObjects![indexPath.section] as! BookDetail
cell.bLabel?.text = histBooks[indexPath.row]
但是,如何使用cell.bLabel?.text
在bookDetail
处获取数据?预先感谢。