objective c - Conversion error OBJ-C to Swift 3 -


i trying convert ezaudio (https://github.com/syedhali/ezaudio) objective-c library swift 3. doing "ezaudioplayfileexample" part in it.

objective-c

- (void)openfilewithfilepathurl:(nsurl*)filepathurl {     self.audiofile = [ezaudiofile audiofilewithurl:filepathurl];     self.filepathlabel.text = filepathurl.lastpathcomponent;      //     // plot whole waveform     //     self.audioplot.plottype = ezplottypebuffer;     self.audioplot.shouldfill = yes;     self.audioplot.shouldmirror = yes;      //     // audio data 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 url!)          //         // plot whole waveform         //         self.plot.plottype = .buffer         self.plot.shouldfill = true         self.plot.shouldmirror = true          //         // audio data 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 line float no subscript members         })     } 

i know float parameter have no subscript members [0]. want convert objective-c code. or here use library's swift version. note: want "ezaudioplayfileexample" in it.

float **waveformdata unsafemutablepointer. have use unsafemutablepointer in swift 3.0. can use unsafemutablepointer in swift like

unsafemutablepointer<unsafemutablepointer<float>> 

you use like

self.audiofile.getwaveformdata(completionblock: {(_ waveformdata: unsafemutablepointer<unsafemutablepointer<float>>, _ length: int) -> void in             weakself?.plot.updatebuffer(waveformdata[0], withbuffersize: length)           }) 

i have downloaded older version swift implementation of ezaudio , converted swift 3.0. available @ link
don't know or not may build on top of this. refer issue being reported on github page


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -