[futurebasic] Re: [FB] Dynamic array of CoreFoundation types

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2011 : Group Archive : Group : All Groups

From: Brian S <fblistserve@...>
Date: Sun, 17 Jul 2011 09:20:12 -0700
On Jul 17, 2011, at 5:15 AM, Steve wrote:

> 
> On Jul 17, 2011, at 1:46 AM, Brian S wrote:
> 
>> 
>> On Jul 16, 2011, at 10:45 PM, Brian S wrote:
>> 
>>> 
>>> On Jul 16, 2011, at 5:11 PM, Robert Purves wrote:
>>> 
>>>>> 
>>>>> Sure do wish Dynamic Arrays could use CFStringRef
>>> 
>>> 
>>> And even if they do why not use CFArrays?
>> 
>> The question is more for the person who asked Robert.
>> 
>> 
>> Brian S
> 
> That person is me and it's because I don't know how to use CFArrays for my purpose.  I like the simplicity of dynamic arrays, in adding, deleting, and read/write to disk.
I can understand how everyone has preferences, but all of those functions are easily doable in CFArrays. Once everything is defined things are simple: e.g. to write the array to a file is: fn CFArrayWriteToFile( mutArray, parentRef, gTheAppFileName ) and reading the array from file to array is: array    = fn CFArrayCreateWithContentsOfFile( fileRef ). All these functions are in the CFAdditions written by Bernie.



> I have large record structures comprised of CFStringRefs that are being converted to pascal strings and placed into the Dynamic array record structures.
Obviously, using CFArrays and CFStrings ( and other CF types ) avoids the conversion back and forth to pascal strings. My apps also use record structures that were converted to CFArrays of CFDictionary records. It works well.

>  Robert's example is encouraging but it is a simple array of a single CFString.
And CFArrays don’t have this issue. They hold any CF type ( CFNumber, CFDate, CFString , CFDictionary etc. )

Steve - if you can post an example of what you think won’t work with CFArrays, maybe the list can help. Bernie and I have used CFArrays successfully and I haven’t found any major limitations yet.

Brian S