Sitemap
CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Member-only story

Core Foundation — Arrays With non-CF Objects

--

A Tutorial on CFArray Containing non-CF Objects

Image by MustangJoe from Pixabay

Introduction

In the two previous posts (Working with Arrays and Working with Mutable Arrays) we stored Core Foundation objects, in particular CFString objects, inside the CFArray (or CFMutableArray). In the current post, we are going to store non-CF objects.

The Source Code

The source code for this post can be found here. (Or git clone git@github.com:pmatsinopoulos/cf_WorkingWithArrays.git and then git checkout array-with-non-cf-objects).

The main() Function

Let’s have a look at the main() function first. It is quite simple:

  • lines 6–9: We call the function CFArrayCreateMutable() in order to create the mutable array. We use the default allocator (kCFAllocatorDefault), and we pass a custom array callbacks structure: kTemperatureCallbacks. This last callbacks structure is very important, because it will tell how we will manage the memory of the elements of the array. It will also…

--

--

CodeX
CodeX

Published in CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Panos Matsinopoulos
Panos Matsinopoulos

Written by Panos Matsinopoulos

Software Writer, Reader and Classical Music Lover.

No responses yet