Alexsander Alexsander - 6 months ago 59
Swift Question

Definition conflicts with previous value in Swift 2.0

I updated Xcode to version 7 and Swift 2.0. My application works and there are not any errors in Xcode 6 with Swift 1.2. I now get the error "Definition conflicts with previous value" in method

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
and I see Previous definition of '
tableView
' is here

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if searchPredicate == nil {
return arrayItem.count ?? 0
} else {
return arrayFilterOfNames.count ?? 0
}
}


Error is here

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

if searchPredicate == nil {
var currentString = arrayItem[indexPath.row]
var urlULTRA: NSURL!
var ultraDirectory = fileManager.URLsForDirectory(NSSearchPathDirectory.DocumentDirectory, inDomains: NSSearchPathDomainMask.UserDomainMask)
if var ultraURL: NSURL = ultraDirectory.first as? NSURL {
urlULTRA = ultraURL.URLByAppendingPathComponent(currentString)
}
var ultraMediaPlayer = AVPlayerItem(URL: urlULTRA)
var ultraCommonMetaData = ultraMediaPlayer.asset.commonMetadata
for ultraData in ultraCommonMetaData {
if ultraData.commonKey == "title" {
// println("ultra data equals \(ultraData.stringValue)")
nameSongForPass = ultraData.stringValue
}
if ultraData.commonKey == "artist" {
nameArtistForPass = ultraData.stringValue
}
if ultraData.commonKey == "album" {
nameAlbumForPass = ultraData.stringValue
}
if ultraData.commonKey == "artwork" {
imageSongForPass = ultraData.dataValue
}
}

cell.nameSong?.text = nameSongForPass
if nameAlbumForPass != nil {
cell.artistAlbumName?.text = "\(nameArtistForPass) - \(nameAlbumForPass)"
} else {
cell.artistAlbumName?.text = "\(nameArtistForPass)"
}

if imageSongForPass != nil {
cell.imageSongs?.image = UIImage(data: imageSongForPass)
} else {
cell.imageSongs?.image = UIImage(named: "Notes100.png")
}
} else {
var name: String! = arrayFilterOfNames[indexPath.row]
cell.nameSong.text = name
}
return cell
}

Answer

The return value of tableView:cellForRowAtIndexPath is declared as optional

... -> UITableViewCell?
Comments