我无法将此objectiveC代码转换为swift

时间:2016-07-07 10:55:32

标签: objective-c swift cmsamplebufferref

1.我正在将目标c的反向音频功能转换为swift,以便我可以将swift代码集成到我的程序中,但是这几行代码是不可理解的

2.这是以下目标-c代码:

    CMSampleBufferRef sample;

    NSMutableArray *samples = [[NSMutableArray alloc] init];

    while (sample != NULL) {
    sample = [readerOutput copyNextSampleBuffer];

    if (sample == NULL)
        continue;

    [samples addObject:(__bridge id)(sample)];

    CFRelease(sample);
    }

1 个答案:

答案 0 :(得分:2)

您显示的代码可以转换为Swift:

var samples: [CMSampleBuffer] = []
while let sample = readerOutput.copyNextSampleBuffer() {
    samples.append(sample)
}