Hello, I would like to know what is the equivalent of Swift 3
mySong.contains
for Swift 2 on Xcode 7 (because I want to create an application for iPhone 4). Excuse me for my english because I am french... and google translation help me
My code :
func gettingSongName(){
let folderURL = NSURL(fileURLWithPath: NSBundle.mainBundle().resourcePath!)
do{
let songPath = try NSFileManager.defaultManager().contentsOfDirectoryAtURL(folderURL, includingPropertiesForKeys: nil, options: .SkipsHiddenFiles)
for song in songPath{
var mySong = song.absoluteString
if mySong.contains(".mp3") { // Value of type 'String' has no member 'contains'
let findString = mySong.components(separatedBy: "/") // Value of type 'String' has no member 'components'
mySong = findString[findString.count-1]
mySong = mySong.replacingOccurrences(of: "%20", with: " ") // Value of type 'String' has no member 'replacingOccurences'
mySong = mySong.replacingOccurrences(of: "e%CC%81", with: "é") // Value of type 'String' has no member 'replacingOccurences'
mySong = mySong.replacingOccurrences(of: "e%CC%82", with: "ê") // Value of type 'String' has no member 'replacingOccurences'
mySong = mySong.replacingOccurrences(of: ".mp3", with: "") // Value of type 'String' has no member 'replacingOccurences'
songs.append(mySong)
print(mySong)
}
}
myTableView.reloadData()
}catch{
}
}
thank you in advance, npn.dev
I am using range string
method in swift 2 and Xcode 7.3.1
let string = "This is only a test"
if string.rangeOfString("only") != nil {
print("yes")
}
Hope it will help you.