UITableViewCell具有文档文件夹中的重复项

时间:2015-08-01 11:47:20

标签: ios xcode swift uitableview

我有几个UITableViewControllers,他们有从文件夹到iOS设备的数据。我使用帮助AVMetaDataItem从mp3文件导出艺术家的名字。我有几个名字,我有重复。如何从UITableViewCell删除重复项?

    var cellStrings: String!
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! UITableViewCell

      var dataForCell = mp3Files[indexPath.row]
    var generalURL: NSURL!

    var documentFolder = fileManager.URLsForDirectory(NSSearchPathDirectory.DocumentDirectory, inDomains: NSSearchPathDomainMask.UserDomainMask)

    if var urlFromFolder: NSURL = documentFolder.first as? NSURL {
        generalURL = urlFromFolder.URLByAppendingPathComponent(dataForCell)
        println("general \(generalURL)")
    }

    var player = AVPlayerItem(URL: generalURL)
    var metaData = player.asset.commonMetadata as! [AVMetadataItem]
    for item in metaData {
        if item.commonKey == "artist" {
            nameArtist = item.stringValue
        }
    }

    cell.textLabel?.text = nameArtist

    return cell
}

enter image description here

0 个答案:

没有答案