Re: How to store C Arrays as a Property or iVar?


 


On Aug 18, 2017, at 2:38 PM, Alex Zavatone <zav@...> wrote:

In that light, is my suggestion useless overhead?

(IIRC you suggested using an NSMutableArray of NSNumbers?) Honestly, it depends. It does have overhead, although not as much as it used to, since NSNumbers of reasonable-size integers don't allocate any memory (they're just tagged pointers.) On the plus side, you get array bounds checking, and it's easy to grow the array dynamically if you ever need to.

If you don't need high performance (e.g. you're not doing math-y stuff with these arrays) and you're not allocating millions of these, NSMutableArray is reasonable. Especially for those who aren't super comfortable with C.

—Jens

Join cocoa@apple-dev.groups.io to automatically receive all group messages.