Ios7 单个UITableViewCell的标识符?

Ios7 单个UITableViewCell的标识符?,ios7,uitableview,Ios7,Uitableview,我正在尝试创建一个非常简单的应用程序,在UITableView中显示歌曲列表。然后用户可以选择一首歌曲,歌曲将开始播放。我还没有实现AVAudioPlayer。我现在还不想处理这个问题。现在我只使用test-NSLog语句来测试tableView:didSelectRowAtIndexPath:method。这是我的密码 - (void) tableView: (UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)inde

我正在尝试创建一个非常简单的应用程序,在UITableView中显示歌曲列表。然后用户可以选择一首歌曲,歌曲将开始播放。我还没有实现AVAudioPlayer。我现在还不想处理这个问题。现在我只使用test-NSLog语句来测试tableView:didSelectRowAtIndexPath:method。这是我的密码

- (void) tableView: (UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
    switch (indexPath.row) {
        case 0:
            NSLog(@"Play Stay");
            break;
        case 1:
            NSLog(@"Play She Was Young");
            break;
        case 2:
            NSLog(@"Play Zombie Song");

        default:
            break;
    }
} else {
    //Uh oh I did not create this section.}

}
请注意,这些单元格是通过编程方式创建的。我在interface builder中有一个原型单元,这三个单元是通过编程方式构建的。这些不是静态单元。它们是动态细胞

问题是,我相信一定有更好的方法。如果我更改这些单元格的顺序,那么NSLog语句将与单元格上的UILabel不匹配,对吗?编写此代码的更好方法是什么?可能为每个单元格创建一个字符串ID。但是我应该在哪里存储字符串ID呢?我应该将其存储为TableViewCell.h的@property吗? 如何为每个单元格创建标识符


我看到了一个非常好的解决方案,但我不能使用它,因为我没有一个静态单元格来创建IBOutlet

而不是使用在方法
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(nsindepath*)indepath中获得的单元格本身中的信息

例如,在自定义单元格中,u使用somthing、songName和songPath(存储路径) 这只是一个例子,当你在自定义单元格中有一个插座作为标签时,我使用了单元格中标签将使用的字符串


视图控制器


   @interface CustomCell : UITableViewCell
   @property (nonatomic, retain) NSString *SongName;//to hold the song name
   @property (nonatomic,retain) NSString *SongPath;//put this it may help for your song detection
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
    CustomCell *cell = (CustomCell *) [tableView cellForRowAtIndexPath:indexPath];//you can get the cell itself and all associated properties for the cell after rearranging it won't change 
    NSString *songName = cell.SongName;
    NSLog(@"%@",songName);
    //suppose u want to get to paly use the information in the cell
    //cell.SongPath ->gives the url(location of file) use it to paly song



 }