countForFetchRequest in Swift 2.0

前端 未结 2 1900
耶瑟儿~
耶瑟儿~ 2021-02-20 10:48

I am trying to use the countForFetchRequest method on a managed object context in Swift 2.0.

I note that the error handling for executeFetchRequest

2条回答
  •  时光取名叫无心
    2021-02-20 11:00

    You need to do like this:

    let error = NSErrorPointer()
    let fetchResults = coreDataStack.context.countForFetchRequest(fetchRequest, error: error)
    print("Count \(fetchResults)")
    

    This is the code for Swift 2.0

提交回复
热议问题