Swift: How to filter in Core Data

后端 未结 2 386
你的背包
你的背包 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:18

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

    let filter = "products"
    let predicate = NSPredicate(format: "type = %@", filter)
    fetchRequest.predicate = predicate
    

提交回复
热议问题