ios - how do you append tableview cells to correct headers? -
i have 2 viewcontrollers. in viewcontroller1, can select items. when item selected stored in core data. in viewcontroller2 want present items selected tableview headers.
some pictures (can't embed because of reputation):
as can see on these photos, alright when same item selected. when select new item gets duplicated. because of row code:
func tableview(_ tableview: uitableview, numberofrowsinsection section: int) -> int { return cartarray.count } so counts 2 items , both sections 2 items. wondering how append item under correct section.
my coredata array this:
[<cart: 0x6180004810e0> (entity: cart; id: 0xd000000002940000 <x-coredata://e4d1962c-c414-4c3a-a3bd-b300be78c00b/cart/p165> ; data: { selectedcategory = shirts; selectedid = 101; selectedname = "white shirt"; selectedprice = 110; selectedquantity = 2; }), <cart: 0x6180004828a0> (entity: cart; id: 0xd000000002980000 <x-coredata://e4d1962c-c414-4c3a-a3bd-b300be78c00b/cart/p166> ; data: { selectedcategory = dresses; selectedid = 103; selectedname = "blue dress"; selectedprice = 125; selectedquantity = 1; })] and sections:
public func numberofsections(in tableview: uitableview) -> int { return cartarray.count } and title:
func tableview(_ tableview: uitableview, titleforheaderinsection section: int) -> string?{ let sections = cartarray let currentsection = sections?[section] return currentsection?.selectedcategory } thanks!!


Comments
Post a Comment