Platforms to show: All Mac Windows Linux Cross-Platform

CFArrayMBS class

Super class: CFObjectMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
class CoreFoundation MBS MacCF Plugin ✅ Yes ❌ No ❌ No ✅ Yes All
A class for a core foundation Array.
// copy names of recent items in Xojo Preferences

dim names() as string
dim c as new CFPreferencesMBS

dim o as CFObjectMBS = c.CopyAppValue(NewCFStringMBS("Recent Items Dict"), NewCFStringMBS("com.realsoftware.realstudio"))

if o isa CFArrayMBS then
dim a as CFArrayMBS = CFArrayMBS(o)

dim u as Integer = a.Count-1
for i as Integer = 0 to u

o = a.Item(i)

if o isa CFDictionaryMBS then
dim d as CFDictionaryMBS = CFDictionaryMBS(o)

dim no as CFObjectMBS = d.Value(NewCFStringMBS("Name"))
if no isa CFStringMBS then

dim ns as CFStringMBS = CFStringMBS(no)

names.Append ns.str
end if
end if
end if

MsgBox Join(names,EndOfLine)

If the release property is true, the destructor of this class will release the array reference.

From CFArrayMBS.h:

CFArray implements an ordered, compact container of pointer-sized values. Values are accessed via integer keys (indices), from the range 0 to N-1, where N is the number of values in the array when an operation is performed. The array is said to be "compact" because deleted or inserted values do not leave a gap in the key space -- the values with higher-numbered indices have their indices renumbered lower (or higher, in the case of insertion) so that the set of valid indices is always in the integer range [0, N-1]. Thus, the index to access a particular value in the array may change over time as other values are inserted into or deleted from the array.

Arrays come in two flavors, immutable, which cannot have values added to them or removed from them after the array is created, and mutable, to which you can add values or from which remove values. Mutable arrays have two subflavors, fixed-capacity, for which there is a maximum number set at creation time of values which can be put into the array, and variable capacity, which can have an unlimited number of values (or rather, limited only by constraints external to CFArray, like the amount of available memory). Fixed-capacity arrays can be somewhat higher performing, if you can put a definate upper limit on the number of values that might be put into the array.

As with all CoreFoundation collection types, arrays maintain hard references on the values you put in them, but the retaining and releasing functions are user-defined callbacks that can actually do whatever the user wants (for example, nothing).

Computational Complexity The access time for a value in the array is guaranteed to be at worst O(lg N) for any implementation, current and future, but will often be O(1) (constant time). Linear search operations similarly have a worst case complexity of O(N*lg N), though typically the bounds will be tighter, and so on. Insertion or deletion operations will typically be linear in the number of values in the array, but may be O(N*lg N) clearly in the worst case in some implementations. There are no favored positions within the array for performance; that is, it is not necessarily faster access values with low indices, or to insert or delete values with high indices, or whatever.

This class works on Windows with QuickTime 7 installed.
Subclass of the CFObjectMBS class.

Super class CFObjectMBS

Sub classes:

Some useful global functions for this class:

Some methods using this class:

Some examples using this class:

Blog Entries

Release notes

  • Version 23.2
    • Added AsArray function for CFArrayMBS class to convert to array of variant.

The items on this page are in the following plugins: MBS MacCF Plugin.

CFAbsoluteTimeMBS   -   CFAttributedStringMBS

The biggest plugin in space...