i need to fetch IF there is anything in the sqlite in a UITableview return nil if not "and not crash"
var fetchedResultsController: NSFetchedResultsController{
var fetched = Profil.fetchAllSortedBy("hostname", ascending: true, withPredicate: nil, groupBy: nil, delegate: self)
return self.fetchedResultsController
}
how is it possible to fetch and and if it's nil it wont return anything ?
i tried this :
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
but it returns in both cases this error :
xxx[8708:637429] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[xxx.Profil fetchAllSortedBy:ascending:withPredicate:groupBy:delegate:]: unrecognized selector sent to class 0x107b1eab0'
here's the screenshot on how things are set up