خرید بک لینک

Vote count: 0

I have a tableview and the data inside each cell is an NSMutableArray. I want to delete a row of the tableview each time I swipe left and press the delete button. However it is difficult with an NSMutableArray. I get a Sigabrt everytime I input the code toDoItems.removeObjectAtIndex(indexPath.row).

The error I get is Terminating with uncaught exception of type NSException

Any help on this problem?

Here is code relating to the problem.

My NSMutableArray variable

var toDoItems:NSMutableArray! = NSMutableArray()

My commitEditingStyle function:

func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath){

    if(editingStyle == UITableViewCellEditingStyle.Delete){


        //This code gives me the error and Sigabrt
        toDoItems.removeObjectAtIndex(indexPath.row)



        tbl?.reloadData();


    }

My numberOfRowsInSection function:

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{

    if (self.resultSearchController.active)
    {
        retu self.filteredAppleProducts.count
    }
    else
    {
        retu toDoItems.count
    }

My cellForRowAtIndexPath function:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) ->
    UITableViewCell{

        let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! TableView
        if (self.resultSearchController.active)
        {
            cell.lbl.text = self.filteredAppleProducts[indexPath.row]

            retu cell
        }
        else
        {
            let toDoItem:NSDictionary = toDoItems.objectAtIndex(indexPath.row) as! NSDictionary
            cell.lbl.text = toDoItem.objectForKey("itemTitel") as? String

            retu cell
        }


}

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 24 خرداد 1395 ساعت: 8:21

صفحه بندی