标签:
分页读取数据库
class func DBGoodsInfoReadWithCondtions(limitData:Int,fetchSet:Int) -> [AnyObject]{
let app = DBAppdalegateObject()
let request = NSFetchRequest()
let entity = NSEntityDescription.entityForName("GoodsInfo", inManagedObjectContext: app.managedObjectContext!)
request.entity = entity
// request.fetchBatchSize = 10 尚未搞清楚 这个属性与fetchLimit 有什么区别 似乎是一个读到内存 ?
request.fetchLimit = limitData //一次性至少从数据库中读取多少条
request.fetchOffset = limitData*fetchSet // 从数据库中第几个索引开始读取
var error: NSError? = nil
let idArray = app.managedObjectContext!.executeFetchRequest(request, error: &error)! as Array
return app.managedObjectContext!.executeFetchRequest(request, error: &error)!
}
标签:
原文地址:http://www.cnblogs.com/madaha/p/4206281.html