ios - How to delete cells in tableView with matching core data in swift 3? -
i have core data table named menu , have inside many items , have inside identity
, show
columns , have static nsmutabledictionary
(allmenu) datas , want check menu items display in tableview nsmutabledictionary inside (identity) == core data menu table inside identity
, show == true , "cellidentifier" == "menu" ones in allmenu data, try doesn't work codes under below.
my coredata
menu table;
id string name string identity string show boolean
my nsmutabledictionary table view menu data
allmenu = [ [ "cellidentifier" : "menu", "id" : "1", "name" : "menu 1", "identity" : "m1", "show" : true ], [ "cellidentifier" : "menu", "id" : "2", "name" : "menu 2", "identity" : "m2", "show" : false ], [ "cellidentifier" : "menu", "id" : "3", "name" : "menu 3", "identity" : "m3", "show" : true ], [ "cellidentifier" : "oldmenu", "id" : "4", "name" : "menu 4", "identity" : "m4", "show" : true ], [ "cellidentifier" : "menu", "id" : "5", "name" : "menu 5", "identity" : "m5", "show" : true ], [ "cellidentifier" : "oldmenu", "id" : "6", "name" : "menu 6", "identity" : "m7", "show" : true ] ]
my codes
var getitems = 0 let fetchrequestfz = nsfetchrequest<nsfetchrequestresult>(entityname:"menu") { let ketone = try context.fetch(fetchrequestfz) as! [menu] getitems = getone.count } catch let error nserror { print(error) } ix in 0..<getitems { let fetchrequestf = nsfetchrequest<nsfetchrequestresult>(entityname:"menu") let predicatek = nspredicate (format:"identity = %@", allmenu[ix]["identity"] as! string) fetchrequestf.predicate = predicatek { let gettwo = try context.fetch(fetchrequestf) as! [menu] var onlygetlastones = 0 ia in 0 ..< gettwo.count { onlygetlastones += 1 if onlygetlastones <= 1 { if (gettwo[0].show == false){ self.tableview.beginupdates() self.celldescriptors.remove(at: ia) self.tableview.endupdates() }else{ } } } } catch let error nserror { print(error) } }
Comments
Post a Comment