Nishad Arora Nishad Arora - 6 months ago 19
Objective-C Question

I am unable to convert this objectiveC code into swift

1.I am converting a reverse audio function of objective c into swift so that I can integrate the swift code into my program but these few lines of codes are not understandable

2.This is the following objective-c code:

CMSampleBufferRef sample;

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

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

if (sample == NULL)

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



The code you have shown can be converted to Swift as:

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