Ich versuche, eine EZAudio (https://github.com/syedhali/EZAudio) Objective-C-Bibliothek in Swift 3 zu konvertieren. Ich mache den "EZAudioPlayFileExample" -Teil darin.Konvertierungsfehler OBJ-C nach Swift 3
Objective-C
- (void)openFileWithFilePathURL:(NSURL*)filePathURL
{
self.audioFile = [EZAudioFile audioFileWithURL:filePathURL];
self.filePathLabel.text = filePathURL.lastPathComponent;
//
// Plot the whole waveform
//
self.audioPlot.plotType = EZPlotTypeBuffer;
self.audioPlot.shouldFill = YES;
self.audioPlot.shouldMirror = YES;
//
// Get the audio data from the audio file
//
__weak typeof (self) weakSelf = self;
[self.audioFile getWaveformDataWithCompletionBlock:^(float **waveformData,
int length)
{
[weakSelf.audioPlot updateBuffer:waveformData[0]
withBufferSize:length];
}];
}
Swift 3
func openFileWithFilePathURL(filePathURL: NSURL) {
self.audioFile = EZAudioFile(url: filePathURL as URL!)
//
// Plot the whole waveform
//
self.plot.plotType = .buffer
self.plot.shouldFill = true
self.plot.shouldMirror = true
//
// Get the audio data from the audio file
//
weak var weakSelf = self
self.audioFile.getWaveformData(completionBlock: {(_ waveformData: Float, _ length: Int) -> Void in
weakSelf?.plot.updateBuffer(waveformData[0], withBufferSize: length) // error in this line as Float as no subscript members
})
}
Ich weiß Parameter Float haben keine Index-Mitglieder wie [0]. Aber ich möchte den Objective-C-Code konvertieren. ODER jemand hier benutzt die Swift-Version dieser Bibliothek. Hinweis: Ich möchte das "EZAudioPlayFileExample" darin.
Warum Sie die Bibliothek zu schnellen konvertieren möchten Sie Ziel-C-Bibliotheken in swift Projekt mithilfe Überbrückung Header verwenden können –
@AravindAR Sie richtig mache ich mit Überbrückung Header. Der obige Code stammt vom Implementierungsteil (ViewController.m). Also muss ich das in Swift konvertieren –
"Ich weiß Float-Parameter haben keine tiefgestellten Mitglieder wie [0]" In Objective-C, es ist 'float ** signalformData', beachten Sie die beiden' * '. – Larme