delete UITableView row apple addMusic example
Posted
by Pavan
on Stack Overflow
See other posts from Stack Overflow
or by Pavan
Published on 2010-03-21T19:38:20Z
Indexed on
2010/03/21
19:41 UTC
Read the original article
Hit count: 374
Hi, i am trying to add a swipe to delete feature to the addmusic example project (downloaded free from apple) so that i am able able to delete a specific row.
Ive added the following code just so that i can enable to delete feature but i dont know how to remove the song from the list which i believe to be the mediaItemCollection and actually deleting it from the userMediaItemCollection which is used to queue the songs to the player.
- (void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
// If row is deleted, remove it from the list.
if (editingStyle == UITableViewCellEditingStyleDelete)
{
// delete your data item here
// Animate the deletion from the table.
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationFade];
}
}
The swipe to delete feature works nicely, the delete button only appears when swiped, but when i click delete, a SIGBART error occurs, the whole application freezes, (although the musix does continue to play, lol). Can someone please tell me how i can delete the row at that index and how i can delete it from the mediaitemcollection please.
When taking that single line of code out:
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationFade];
the swipe to delete works, except that it does not delete anything obviously since i havent added any actual delete functionality/coding that needs to be done.
All ideas appreciated.
© Stack Overflow or respective owner