将mediaItemCollection数据放置在UITableView中

将mediaItemCollection数据放置在UITableView中,uitableview,xcode4,mpmediaitemcollection,Uitableview,Xcode4,Mpmediaitemcollection,我需要一些帮助来将mediaItemCollection数据放置在UITableView中 代码: mediaItemCollection是我需要放入我的UITableView: 通过声明MPMediaItemCollection并设置其内容,我可以在更新UITableView的数据时读取mediaItemCollection - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSInde

我需要一些帮助来将
mediaItemCollection
数据放置在
UITableView

代码:

mediaItemCollection
是我需要放入我的
UITableView

:

通过声明
MPMediaItemCollection
并设置其内容,我可以在更新
UITableView
的数据时读取
mediaItemCollection

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"song_cell"];

    cell = [[UITableViewCell alloc]
            initWithStyle:UITableViewCellStyleSubtitle 
            reuseIdentifier:@"song_cell"];

    MPMediaItem *anItem = [[collection items] objectAtIndex:indexPath.row];

    cell.textLabel.text = [anItem valueForProperty:MPMediaItemPropertyTitle];
    cell.detailTextLabel.text = [anItem valueForProperty:MPMediaItemPropertyArtist];

    [tableView reloadData];
}
:)

通过声明
MPMediaItemCollection
并设置其内容,我可以在更新
UITableView
的数据时读取
mediaItemCollection

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"song_cell"];

    cell = [[UITableViewCell alloc]
            initWithStyle:UITableViewCellStyleSubtitle 
            reuseIdentifier:@"song_cell"];

    MPMediaItem *anItem = [[collection items] objectAtIndex:indexPath.row];

    cell.textLabel.text = [anItem valueForProperty:MPMediaItemPropertyTitle];
    cell.detailTextLabel.text = [anItem valueForProperty:MPMediaItemPropertyArtist];

    [tableView reloadData];
}