Next Page > Hide TOC

NSUniqueIDSpecifier Class Reference

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

Overview

Specifies an object in a collection (or container) by unique ID. This specifier works only for objects that have an ID property. The unique ID object passed to an instance of NSUniqueIDSpecifier must be either an NSNumber object or an NSString object. The exact type should match the scripting dictionary declaration of the ID attribute for the relevant scripting class.

You can expect that the ID property will be read only for any object that supports it. Therefore a scripter can obtain the unique ID for an object and refer to the object by the ID, but cannot set the unique ID.

You don’t normally subclass NSUniqueIDSpecifier.

The evaluation of NSUniqueIDSpecifier objects follows these steps until the specified object is found:

  1. If the container implements a method whose selector matches the relevant valueIn<Key>WithUniqueID: pattern established by scripting key-value coding, the method is invoked. This method can potentially be very fast, and it may be relatively easy to implement.

  2. As is the case when evaluating any script object specifier, the container of the specified object is given a chance to evaluate the object specifier. If the container class implements the indicesOfObjectsByEvaluatingObjectSpecifier: method, the method is invoked. This method can potentially be very fast, but it is relatively difficult to implement.

  3. An NSWhoseSpecifier object that specifies the first object whose relevant 'ID ' attribute matches the ID is synthesized and evaluated. The NSWhoseSpecifier object must search through all of the keyed elements in the container, looking for a match. The search is potentially very slow.

Tasks

Initializing a Unique ID Specifier

Accessing Unique ID Information

Instance Methods

initWithContainerClassDescription:containerSpecifier:key:uniqueID:

Returns an NSUniqueIDSpecifier object, initialized with the given arguments.

- (id)initWithContainerClassDescription:(NSScriptClassDescription *)classDesc containerSpecifier:(NSScriptObjectSpecifier *)container key:(NSString *)property uniqueID:(id)uniqueID

Parameters
classDesc

The class description for the new object.

container

The container for the new object.

property

The property for the new object.

uniqueID

The unique ID for the new object.

uniqueID must be an instance of NSNumber or NSString. The type should match the declared type of the attribute of the specified scriptable class whose four-character code is 'ID '.

Return Value

An NSUniqueIDSpecifier object, initialized with the given arguments.

Discussion

Invokes the super class’s initWithContainerClassDescription:containerSpecifier:key: method and sets the ID to uniqueID.

Availability
Related Sample Code
Declared In
NSScriptObjectSpecifiers.h

setUniqueID:

Sets the ID encapsulated by the receiver.

- (void)setUniqueID:(id)uniqueID

Parameters
uniqueID

The ID for the receiver.

uniqueID must be an instance of NSNumber or NSString. The type should match the declared type of the attribute of the specified scriptable class whose four-character code is 'ID '.

Discussion

Although NSUniqueIDSpecifier supports setting the unique ID, the ID for a specified object is likely to remain static over the life of the object.

Availability
See Also
Declared In
NSScriptObjectSpecifiers.h

uniqueID

Returns the ID encapsulated by the receiver.

- (id)uniqueID

Return Value

The ID encapsulated by the receiver.

Availability
See Also
Declared In
NSScriptObjectSpecifiers.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.