开发者

commitEditingStyle in tableview datasource methods

i had nsmutablearray hold data one two three four five...

i need to delete data from my commitEditingStyle...

   - (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
    {

        if (editingStyle == UITableViewCellEditingStyleDelete) 
        {

        [favoriteListArray removeObjectAtIndex:indexPath.row];

    //  [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
  //    [tableView deleteRowsAtIndexPaths:[favoriteListArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
        }
    }

What do to delete selected list.

my application get crashed

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections. The number of sections contained in the开发者_如何学JAVA table view after the update (4) must be equal to the number of sections contained in the table view before the update (5), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).'

@thanks in advance


If you want to delete NSMutable Array when it has no objects then simply check

if([favoriteListArray count]<1)

    {
       [favoriteListArray release];//if it is not autorelease;
       favoriteListArray=nil;
    }

Edit:

for deleting entry from table

you need to reload the table now NSMutableArray not having that entry so this time it shows updated result.


- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{

    if (editingStyle == UITableViewCellEditingStyleDelete) 
    {
        UIDevice *device_ID = [UIDevice currentDevice];
        NSString *deviceUDID = [device_ID uniqueIdentifier];
        NSLog(@"deviceUDID %@",deviceUDID);
        NSString *url=@"http://partytemperature.com/favoritevent_delete.php?eventid=";
        url=[url stringByAppendingFormat:@"%@&deviceid=%@",aEventInfo.event_ID,deviceUDID];
        NSLog(@"Url value %@",url);
        [self parsePopularEvent:[[NSURL alloc]initWithString:url]];
        [[[favoriteListArray objectAtIndex:indexPath.section]eventListArray] removeObjectAtIndex:indexPath.row];
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
        [tableView reloadData];
    }
}

-(void)parsePopularEvent:(NSURL *)url{
    NSXMLParser *xmlParser=[[NSXMLParser alloc]initWithContentsOfURL:url];
    XMLParser *parser=[[XMLParser alloc]initXMLParser];
    [xmlParser setDelegate:parser];
    BOOL success;
    success=[xmlParser parse];
    if (success) {
        NSLog(@"Parsed Success");
    }
    else

    NSLog(@"Error!!!!!");

}

This is deleting option which i done its working perfect........

but i can send only one request for my web service. using xmlparser... I need send every deleted request to my web-service.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜