I am trying to develop a very simple Core Foundation program that uses the function CFStringCreateArrayBySeparatingStrings(). However, it does not work as I expect.
The program is the following:
#include <stdio.h>
#include <CoreFoundation/CoreFoundation.h>
void applier(const void *value, void *context) {
  printf("%s\n", CFStringGetCStringPtr((CFStringRef)value, CFStringGetSystemEncoding()));
}
int main(int argc, const char * argv[]) {
  CFStringRef stringToParse = CFSTR("John Pappas,Mary Foo,Peter Pan");
  CFStringRef separatorString = CFSTR(",");
  
  CFArrayRef array = CFStringCreateArrayBySeparatingStrings(kCFAllocatorDefault, 
                                                            stringToParse, 
                                                            separatorString);
  
  CFArrayApplyFunction(array, 
                       CFRangeMake((CFIndex)0, 
                                   (CFIndex)CFArrayGetCount(array)), 
                       applier, 
                       NULL);
  
  CFRelease(array);
  
  return 0;
}
When I run the program, the output is the following:
John Pappas
(null)
(null)
Program ended with exit code: 0
I don't understand why the 2nd and 3rd values are not printed as expected.
When trying to debug the program, before exiting, the debugger shows that the array does have 3 elements, but the types of its values are not the same type for all. Here is what I am looking at when I stop at the break point with the debugger:
Also, by looking at the debugger, I am a little bit surprised that the elements of the array have values of types that involve NS. I thought that I was using Core Foundation and not Foundation framework. So, I expected the values to have types like CFStringRef.
Can you help me make this program run successfully using Core Foundation API?
