MagicalRecord + Swift如何获取探测?

时间:2014-10-16 10:02:38

标签: ios uitableview core-data swift magicalrecord

我需要获取如果在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'

这里是关于如何设置的屏幕截图

before after enter image description here enter image description here

0 个答案:

没有答案