trying to delete a song from a list UITableView sigbart error - addMusic Example
- by Pavan
hi im trying to implement a delete feature into the addmusic example
this is the code ive added
it doesnt work, i cant get my head around whats wrong. can someone please tell me whats wrong and what i need to do to make sure it works.
- (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)
{
MainViewController *mainViewController = (MainViewController *) self.delegate;
NSUInteger index = [indexPath row];
MPMediaItem *itemToDelete = [mainViewController.userMediaItemCollection mediaItemAtIndex:index];
if ([itemToDelete isEqual:mainViewController.musicPlayer.nowPlayingItem])
{
[mainViewController.musicPlayer skipToNextItem];
}
MPMediaItemCollection *newCollection = [mainViewController.userMediaItemCollection collectionByDeletingMediaItemAtIndex:index];
mainViewController.userMediaItemCollection = newCollection;
NSUInteger indices[] = {0, index};
NSIndexPath *deletePath = [NSIndexPath indexPathWithIndexes:indices length:2];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:deletePath] withRowAnimation:UITableViewRowAnimationFade];
I also get these warnings when i compile the program and run it:
heres the image:
http://www.freeimagehosting.net/uploads/6e42f166b9.png
Any ideas and help appreciated.