Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
831 views
in Technique[技术] by (71.8m points)

ios - How to delete all items if i delete one of them in tableview?

I Have two collectionView one is for main items and other is for Sub Items

Main Item we can consider as iPhone

Sub Items we can consider as headphone of apple

so we can say this two items “One Group”

both items are adding at DidSelectMethod and displaying in tableView

i have one option of delete this item

my requirement is if i delete any of one item from this group my all tableview data should be cleared

Here is the Code i am using to delete Product

//Define Button Action in cellForRowAtIndexPath

cell.btnDelete.addTarget(self, action:#selector(ViewController.btnDeleteTapped(_:)), forControlEvents: .TouchUpInside)
cell.btnDelete.tag = indexPath.row

//Button Action

func btnDeleteTapped(sender: UIButton){

  self.arrProductCart.removeObjectAtIndex(sender.tag)
  self.tblCart.reloadData()
}

MainProduct Array

(
    {
    "addtional_price" = 0;
    "barcode_image" = ".png";
    "cart_unique_id" = 6;
    "chicken_product" = all;
    "created_by" = 2;
    "created_date" = "2015-11-19 21:39:24";
    "deleted_date" = "0000-00-00 00:00:00";
    ids = 151;
    isFromMain = 1;
    "is_deleted" = 0;
    "is_has_addtional_price" = 0;
    "parent_product_unique_id" = 6;
    "product_id" = 53;
    "product_name" = "Black Pepper Chicken";
    "product_parent_id" = 0;
    "product_price" = "7.9";
    "sub_category_type" = "";
    "update_date" = "2016-06-22 17:54:53";
    "updated_by" = 7;
  "parent_product_unique_id" = 6
}

)

SubProduct Array

     {
    "created_by" = 2;
    "created_date" = "2015-11-19 23:11:37";
    "deleted_date" = "0000-00-00 00:00:00";
    ids = 157;
    isFromMain = 0;
    "product_category_id" = 16;
    "product_description" = "Potato";
    "product_id" = 59;
    "product_name" = "Potato";
    "product_parent_id" = 0;
    "product_price" = 2;
    "product_quantity" = 0;
    "sub_category_type" = s;
    "product_unique_id" = 6
}

it that any solution to do this ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...