Swift: How to filter in Core Data

后端 未结 2 387
你的背包
你的背包 2021-02-04 11:53

I\'m using the following code to fetch all the data in \"category\".

let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate

let managedCon         


        
相关标签:
2条回答
  • 2021-02-04 12:10

    You can use .filter on the fetchedResults.

    0 讨论(0)
  • 2021-02-04 12:18

    To "filter" results in Core Data, use NSPredicate like so:

    let filter = "products"
    let predicate = NSPredicate(format: "type = %@", filter)
    fetchRequest.predicate = predicate
    
    0 讨论(0)
提交回复
热议问题