About the UITableView sweep removal problem [Nsmutablearray Removeobjectatindex]

Source: Internet
Author: User

-(void) TableView: (UITableView *) TableView Commiteditingstyle: (uitableviewcelleditingstyle) Editingstyle Forrowatindexpath: (Nsindexpath *) Indexpath {
    
if (Editingstyle = = uitableviewcelleditingstyledelete) {
       
[MyArray RemoveObjectAtIndex:indexPath.row];
        
[TableView Deleterowsatindexpaths:[nsarray Arraywithobject:indexpath] Withrowanimation:uitableviewrowanimatio Nfade];
    }   
else if (Editingstyle = = Uitableviewcelleditingstyleinsert) {
//Create A new instance of the appropriate class, insert it into the array, and add a new row to the table VI ew.
    }   
}


here MyArray is an array is a data member and I've alloc, but when I'm sweeping through the simulator, I always get an error in the Remove, and this is the wrong
2011-06-08 16:51:56.989 view[749:207]-[__nsarrayi removeobjectatindex:]: Unrecognized selector sent to instance 0x4e4b530
2011-06-08 16:51:56.991 view[749:207] * * * terminating app due to uncaught exception ' Nsinvalidargumentexception ', rea Son: '-[__nsarrayi Removeobjectatindex:]: Unrecognized selector sent to instance 0x4e4b530 '

Call stack at first throw:

Workaround:

The array should initialize the called Nsmutablearray I define it as Nsarray.

NSMutablearray * myarray = [[NSMutableArray alloc] init];



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

About the UITableView sweep removal problem [Nsmutablearray Removeobjectatindex]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.