CFStringCreateWithFormatHeader: CFString.h

Creates an immutable CFString object from a formatted string and a variable number of arguments.

CFStringRef CFStringCreateWithFormat (
    CFAllocatorRef alloc, 
    CFDictionaryRef formatOptions, 
    CFStringRef format,
    ...
);
alloc

Pass a reference to an allocator to be used to create the CFString object or pass NULL to request the default allocator.

formatOptions

Pass a reference to a CFDictionary object containing formatting options for the string (such as the thousand-separator character, which is dependent on locale). Currently, these options are an unimplemented feature.

format

Pass a reference to a CFString object that contains a string with printf-style specifiers.

...

Pass a list of variables whose values are to be substituted, in order, for the specifiers in a formatted string. The formatted string is contained by the CFString object referenced by format. If there are multiple variables, separate them with commas.

function result

A reference to an immutable CFString object or NULL if there was a problem creating the object.

DISCUSSION

The CFStringCreateWithFormat creates a CFString object from another CFString object containing a formatted string and a list of arguments. A formatted string is one with printf-style format specifiers embedded in the text such as %d (decimal), %f (double), and %@ (Core Foundation object). The subsequent arguments, in order, are substituted for the specifiers in the character data contained by the created object. You can also reorder the arguments in the string by using modifiers of the form"$n" with the format specifiers (for example, %$2d. These modifiers allow you to easily localize formatted strings by reading them from resources or property-list files.

For more information on supported specifiers, see the relevant section in "Core Foundation String Services Tasks."


© 1999 Apple Computer, Inc. — (Last Updated 9/15/99)