Next Page > Hide TOC

SBElementArray Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/ScriptingBridge.framework
Availability
Available in Mac OS X v10.5 and later.
Declared in
SBElementArray.h

Overview

SBElementArray is subclass of NSMutableArray that manages collections of related SBObject objects. For example, when you ask the Finder for a list of disks, or ask iTunes for a list of playlists, you get the result back as an SBElementArray containing Scripting Bridge objects representing those items.

SBElementArray defines methods beyond those of NSArray for obtaining individual objects. In addition to objectAtIndex:, SBElementArray also defines objectWithName:, objectWithID:, and objectAtLocation:.

Subclassing Notes

The SBElementArray class is not designed for subclassing.

Tasks

Getting Objects in the Array

Getting the Referenced Array

Filtering an Element Array

Instance Methods

arrayByApplyingSelector:

Returns a array containing the results of sending the specified message to each object in the receiver.

- (NSArray *)arrayByApplyingSelector:(SEL)selector

Parameters
selector

A selector identifying the message to be sent to each object in the array.

Return Value

A new array containing the results of sending the selector message to each object in the receiver, starting with the first object and continuing through the element array to the last object.

Discussion

The method identified by selector must not take any arguments and must return an Objective-C object. It should not have the side effect of modifying the receiving array. The order of the items in the result array corresponds to the order of the items in the original array.

Availability
See Also
Declared In
SBElementArray.h

arrayByApplyingSelector:withObject:

Returns a array containing the results of sending the specified message to each object in the receiver.

- (NSArray *)arrayByApplyingSelector:(SEL)selector withObject:(id)argument

Parameters
selector

A selector identifying the message to be sent to each object in the array.

argument

The value for the parameter of the message identified by selector.

Return Value

A new array containing the results of sending the selector message to each object in the receiver, starting with the first object and continuing through the element array to the last object.

Discussion

The method identified by selector must take a single argument—whose value is provided in argument—and must return an Objective-C object. It should not have the side effect of modifying the receiving array. The order of the items in the result array corresponds to the order of the items in the original array.

Availability
See Also
Declared In
SBElementArray.h

get

Forces evaluation of the receiver, causing the real object to be returned immediately.

- (NSArray *)get

Return Value

The object referenced by the receiver.

Discussion

This method forces the evaluation of the current object reference (the receiver), resulting in the return of the referenced object. By default, Scripting Bridge deals with references to objects until you actually request some concrete data from them or until you call the get method.

Availability
Declared In
SBElementArray.h

objectAtLocation:

Returns the object at the given location in the receiver.

- (id) objectAtLocation:(id)loc

Parameters
loc

An object that specifies the absolute position of the object within the array. It can be an integer index, a list of coordinates, a URL, or other determinant. See the discussion for clarification.

Return Value

A reference to the SBObject object identified by loc or nil if the object couldn’t be located.

Discussion

This method is a generalization of objectAtIndex: for applications where the "index" is not simply an integer. For example, Finder can specify objects using a NSURL object as a location. In OSA this is known as "absolute position," a generalization of the notion of “index” in Foundation—it could be an integer, but it doesn't have to be. A single object may even have a number of different "absolute position" values depending on the container.

Availability
See Also
Declared In
SBElementArray.h

objectWithID:

Returns the object in the array with the given identifier.

- (id)objectWithID:(id)identifier

Parameters
identifier

The identifier of one of the receiver's objects.

Return Value

A reference to the identified object or nil if could not be found.

Discussion

This method is provided as an alternative to objectAtIndex: for applications where an identifier is available instead of (or in addition to) an index. A unique ID is generally more stable than an index. For example, it may be more useful to identify a contact in Address Book by its identifier (which doesn't change over time) than by its index in the list of contacts (which can change as contacts are added or removed).

Availability
See Also
Declared In
SBElementArray.h

objectWithName:

Returns the object in the array with the given name.

- (id)objectWithName:(NSString *)name

Parameters
name

The name of one of the receiver's objects.

Return Value

A reference to the designated object or nil if the object couldn’t be found.

Discussion

This method is provided as an alternative toobjectAtIndex: for applications where a name is available instead of (or in addition to) an index. A name is generally more stable than an index. For example, it is typically more useful to identify a mailbox in Mail by its name than by its index in the list of mailboxes.

Availability
See Also
Declared In
SBElementArray.h

Next Page > Hide TOC


© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-05-29)


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.