< Previous PageNext Page > Hide TOC

Creating and Using Ranges

Many Core Foundation take ranges—a structure of type CFRange—as parameters. A range is a measure of a linear segment; it has a beginning location and a length. To create and initialize this structure you can use the convenience function CFRangeMake.

The following code fragment gets the number of subsequent elements in an array that match the first element:

CFRange aRange = CFRangeMake(1, CFArrayGetCount(array) - 1);
// Since start is 1, length of remainder of range is count-1
const void *aValue = CFArrayGetValueAtIndex(array, 0);
CFIndex numVals = CFArrayGetCountOfValue(array, aRange, aValue);


< Previous PageNext Page > Hide TOC


© 2003, 2008 Apple Inc. All Rights Reserved. (Last updated: 2008-03-11)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.