我需要获取如果在UITableview中的sqlite中有任何内容 如果没有"则返回nil而不是崩溃"
var fetchedResultsController: NSFetchedResultsController{
var fetched = Profil.fetchAllSortedBy("hostname", ascending: true, withPredicate: nil, groupBy: nil, delegate: self)
return self.fetchedResultsController
}
如何才能获取,如果它没有,它将不会返回任何内容?
我试过这个:
var fetchedResultsController: NSFetchedResultsController{
if _fetchedResultsController != nil {
return _fetchedResultsController!
}
_fetchedResultsController = Profil.fetchAllSortedBy("hostname", ascending: true, withPredicate: nil, groupBy: nil, delegate: self)
return _fetchedResultsController!
}
var _fetchedResultsController: NSFetchedResultsController? = nil
但在两种情况下都会返回此错误:
xxx[8708:637429] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[xxx.Profil fetchAllSortedBy:ascending:withPredicate:groupBy:delegate:]: unrecognized selector sent to class 0x107b1eab0'
这里是关于如何设置的屏幕截图