trying to delete a song from a list UITableView sigbart error - addMusic Example

Posted by Pavan on Stack Overflow See other posts from Stack Overflow or by Pavan
Published on 2010-03-23T01:06:37Z Indexed on 2010/03/23 1:11 UTC
Read the original article Hit count: 594

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.

© Stack Overflow or respective owner

Related posts about delete

Related posts about row