2017-08-30 7 views
1

こんにちは、 によって私は私がしたいので、スウィフトの同等3スイフト3の「文字列を含む」機能と同等のスウィフト2は何ですか? npn.dev

mySong.contains Xcodeの7(上スウィフト2用

が何であるかを知っていただきたいと思いますiPhone 4用のアプリケーションを作成します)。私はフランス人だから私の英語のためにすみません...と、Google翻訳は

私のコード私を助け:

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{ 

    } 

} 

npn.dev

答えて

2
、事前にあなたに感謝

私はrange stringメソッドをスウィフト2とXcode 7.3.1で使用しています

let string = "This is only a test" 

if string.rangeOfString("only") != nil { 
print("yes") 
} 

お手数ですがお手伝いします。

+0

ありがとう、私は試してみます –

+0

@Pal Singh Anandを理解していません –

+0

あなたが仲間を理解していないものはありますか? –

関連する問題