Difference Between CFArray and NSArray

I am looking for an easier way to manipulate sound buffers on an iPhone. I mainly try to avoid problems with pointers and problems with counting arrays using C, but I do not want to be replaced by numeric objects like NSNumber or NSInteger that I would have to use with NSArray.

I came across CFArray, which seems like it could be a good middle ground. Am I correct in this assumption? Or am I missing something?

+4
source share
3 answers

Not really. CFArray is basically the same as NSArray , you can even throw in between, this is called a free bridge .

CFArray (and its mutable copy) allows you to specify your own callback functions for saving and releasing objects (pointers) in your array, which allows you to store arbitrary pointers (not just NSObject s) in the array and implement your own memory management scheme, but I I doubt that this will lead to any real profit from productivity. For your use case, C arrays are probably the way to go.

+11
source

If performance and memory size are of any importance, which are most likely to be used for real-time audio processing, stick to simple C-arrays and find out how to properly transfer and access the array.

In any case, you need to process the audio in C-arrays, as the IOS Audio Queue and Audio Unit APIs transmit audio using C arrays.

+3
source

If you don't like the C style and want to use some kind of object oriented approach, I would recommend using C ++, for example. std :: vector or similar. Do not use Objective-C for sound that it did not process the signal! Obj-C is great for working with the user interface and connecting objects in the alarm system. Any "real" calculation should always be done in C or in flat C ++.

+1
source

Source: https://habr.com/ru/post/1395906/


All Articles