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 |
Example:
// 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
next
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.
- property count as Integer
- 12 methods
- method AsArray as Variant() New in 23.2
- method clone as CFArrayMBS
- method Constructor
- method Constructor(values() as string)
- method ContainsValue(value as CFObjectMBS) as boolean
- method CountOfValue(value as CFObjectMBS) as Integer
- method Edit as CFMutableArrayMBS
- method FirstIndexOfValue(value as CFObjectMBS) as Integer
- method Item(index as Integer) as CFObjectMBS
- method LastIndexOfValue(value as CFObjectMBS) as Integer
- method writeToFile(file as folderitem, useAuxiliaryFile as boolean) as boolean
- method writeToURL(url as string, atomically as boolean) as boolean
- 3 shared methods
- shared method arrayWithContentsOfFile(file as folderitem) as CFArrayMBS
- shared method arrayWithContentsOfURL(URL as string) as CFArrayMBS
- shared method arrayWithHandle(Handle as Integer) as CFArrayMBS
Super class CFObjectMBS
- 5 properties
- property Handle as Integer
- property Hash as Integer
- property Lasterror as Integer
- property Type as Integer
- property TypeDescription as String
- 9 methods
- method close
- method DeepCopy as CFObjectMBS
- method EncodedData as MemoryBlock
- method Equal(o as CFObjectMBS) as boolean
- method ReleaseObject
- method RetainCount as Integer
- method RetainObject
- method XML as CFBinaryDataMBS
- method XMLdata as String
- shared method NewCFObject(handle as Integer) as CFObjectMBS
Sub classes:
Some useful global functions for this class:
- CreateBundlesFromDirectoryMBS(url as CFURLMBS, type as CFStringMBS) as CFArrayMBS
- GetAllBundlesMBS as CFArrayMBS
- KnownTimeZoneNamesAsCFArrayMBS as CFArrayMBS
Some methods using this class:
- AXUIElementMBS.ActionNames as CFArrayMBS
- AXUIElementMBS.AttributeNames as CFArrayMBS
- AXUIElementMBS.AttributeValues(attribute as CFStringMBS, minindex as Integer, maxindex as Integer) as CFArrayMBS
- CFBundleMBS.ResourceURLsOfType(resourceType as CFStringMBS, subDirName as CFStringMBS) as CFArrayMBS
- CFBundleMBS.ResourceURLsOfTypeForLocalization(resourceType as CFStringMBS, subDirName as CFStringMBS, localizationName as CFStringMBS) as CFArrayMBS
- CFMutableArrayMBS.AppendArray(sourcearray as CFArrayMBS)
- CFPreferencesMBS.CopyApplicationList(userName as CFStringMBS, hostName as CFStringMBS) as CFArrayMBS
- CFPreferencesMBS.CopyKeyList(ApplicationID as CFStringMBS, userName as CFStringMBS, hostName as CFStringMBS) as CFArrayMBS
- CFPreferencesMBS.CopyMultiple(Key as CFArrayMBS, ApplicationID as CFStringMBS, userName as CFStringMBS, hostName as CFStringMBS) as CFDictionaryMBS
- SCPreferencesMBS.KeyList as CFArrayMBS
Some examples using this class:
- /MacCF/CFBundle example
- /MacCF/Dock Items
- /MacCF/iTunes Playlists
- /MacCF/MacOSXProxySettings
- /MacCF/Plist Parsing
- /MacCF/SystemConfiguration/MacOSXProxySettings
- /MacCF/SystemConfiguration/Preferences Test
- /MacOSX/Accessibility services/Accessible Browser
- /MacOSX/Accessibility services/Accessible Test
- /MacOSX/Accessibility services/Control Menu
Blog Entries
- MBS Xojo Plugins, version 23.2pr5
- MBS Xojo / Real Studio Plugins, version 16.4pr4
- MBS Real Studio Plugins, version 13.0pr1
- MBS Real Studio Plugins, version 12.1pr10
- MBS Real Studio Plugins, version 11.2pr9
The items on this page are in the following plugins: MBS MacCF Plugin.
CFAbsoluteTimeMBS - CFAttributedStringMBS
