Receiving modified data from an UITableViewController


#1

Hi,

I have a problem receiving modified data from a UITableViewController.
I have a UIViewController with an ivar to store some data from the iPod. I want to see its items in a table and delete and/or reorder them. And finally return them back to the UIViewController.

I made a UITableViewController as in chapters 11 and 12 but I can’t send them back. Every time I open the table I see the same original collection.

These are my codes:

In my UIViewController.h

The ivar:

[code]MPMediaItemCollection *itemCollection

@property (nonatomic, retain, readwrite) MPMediaItemCollection *itemCollection;
@synthesize itemCollection;
[/code]
In the UIViewController.m
passing data to the UITableViewController:

if (itemCollection) { music *songs = [[music alloc] init]; -> music is my UITableViewController [songs setItemCollection:itemCollection]; -> Data for the UITableView [[self navigationController] pushViewController:songs animated:YES]; }
On the UITableViewController.h
The ivars:

[code]MPMediaItemCollection *itemCollection;
NSMutableArray *itemsArray;

@property (nonatomic, assign) MPMediaItemCollection *itemCollection;
@synthesize itemCollection;
[/code]
And the UITableViewController.m
the code to manage input/output data collection

[code]- (id)init
{
[super initWithStyle:UITableViewStyleGrouped];
itemsArray = [[NSMutableArray alloc] init];
return self;
}

  • (void)viewWillAppear:(BOOL)animated
    {
    [super viewWillAppear:YES];
    itemsArray = [[itemCollection items] mutableCopy];
    }

  • (void)viewWillDisappear:(BOOL)animated
    {
    [super viewWillDisappear:YES];
    [self setItemCollection:[MPMediaItemCollection collectionWithItems:(NSArray *)itemsArray]];
    }
    [/code]

I don’t know were is the problem. Can anyone give my some hint?

Thanks