Next Page > Hide TOC

NSScriptCoercionHandler Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in Mac OS X v10.0 and later.
Companion guide
Declared in
NSScriptCoercionHandler.h
Related sample code

Overview

Provides a mechanism for converting one kind of scripting data to another. A shared instance of this class coerces (converts) object values to objects of another class, using information supplied by classes that register with it. Coercions frequently are required during key-value coding.

Tasks

Accessing the Application’s Handler

Working with Handlers

Class Methods

sharedCoercionHandler

Returns the shared NSScriptCoercionHandler for the application.

+ (NSScriptCoercionHandler *)sharedCoercionHandler

Return Value

The shared NSScriptCoercionHandler for the application.

Availability
Related Sample Code
Declared In
NSScriptCoercionHandler.h

Instance Methods

coerceValue:toClass:

Returns an object of a given class representing a given value.

- (id)coerceValue:(id)value toClass:(Class)toClass

Parameters
value

The value to coerce.

toClass

The class with which to represent value.

Return Value

An object of the class toClass representing the value specified by value. Returns nil if an error occurs.

Availability
Related Sample Code
Declared In
NSScriptCoercionHandler.h

registerCoercer:selector:toConvertFromClass:toClass:

Registers a given object (typically a class) to handle coercions (conversions) from one given class to another.

- (void)registerCoercer:(id)coercer selector:(SEL)selector toConvertFromClass:(Class)fromClass toClass:(Class)toClass

Parameters
coercer

The object that performs the coercion. coercer should typically be a class object.

selector

A selector that specifies the method to perform the coercion. selector should typically be a factory method, and must take two arguments. The first is the value to be converted. The second is the class to convert it to.

fromClass

The class for which instances are coerced.

toClass

The class to which instances of fromClass are coerced.

Availability
Declared In
NSScriptCoercionHandler.h

Next Page > Hide TOC


© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)


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.