2

How can I convert NSRange to Range in Swift?

var copyRange = NSRange()
            copyRange.location = 0
            copyRange.length = 44
            var tmpAudioData = NSMutableData()

            tmpAudioData.appendData(audioPlayer.data?.subdata(in: copyRange)) //<- error at this line  
nilesh
  • 55
  • 10
  • 1
    Try `let range = Range(copyRange, in: audioPlayer.data!)!`. Related, the most voted answer by Martin (not the accepted one by Alex) of: https://stackoverflow.com/questions/25138339/nsrange-to-rangestring-index – Cœur Feb 26 '19 at 08:54

0 Answers0