| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/ScriptingBridge.framework |
| Availability | Available in Mac OS X v10.5 |
| Declared in | SBObject.h |
The SBObject class declares methods that can be invoked on any object in a scriptable application. It defines methods for getting elements and properties of an object, as well as setting a given object to a new value.
Each SBObject is built around an object specifier, which tells Scripting Bridge how to locate the object. Therefore, you can think of an SBObject as a reference to an object in an target application rather than an object itself. To bypass this reference-based approach and force evaluation, use the get method.
Typically, rather than create SBObject instances explictly, you receive SBObject objects by calling methods of an SBApplication subclass. For example, if you wanted to get an SBObject representing the current iTunes track, you would use code like this (where iTunesTrack is a subclass of SBObject):
iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; |
iTunesTrack *track = [iTunes currentTrack]; |
You can discover the names of dynamically generated classes such as iTunesApplication and iTunesTrack by examining the header file created by the sdp tool. Alternatively, you give these variables the dynamic Objective-C type id.
Returns an array containing every child of the receiver with the given class-type code.
- (SBElementArray *)elementArrayWithCode:(DescType)code
A four-character code that identifies a scripting class.
An SBElementArray object containing every child of the receiver whose class matches code.
SBObject subclasses use this method to implement application-specific property accessor methods. You should not need to call this method directly.
SBObject.hForces evaluation of the receiver, causing the real object to be returned immediately.
- (id)get
The object referenced by the receiver.
This method forces the current object reference (the receiver) to be evaluated, 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.
SBObject.hInitializes and returns an instance of an SBObject subclass.
- (id)init
An SBObject object or nil if the object could not be initialized.
Scripting Bridge does not actually create an object in the target application until you add the object returned from this method to an element array (SBElementArray).
SBObject.hReturns an instance of an SBObject subclass initialized with the given data.
- (id)initWithData:(id)data
An object containing data for the new SBObject object. The data varies according to the type of scripting object to be created.
An SBObject object or nil if the object could not be initialized.
Scripting Bridge does not actually create an object in the target application until you add the object returned from this method to an element array (SBElementArray).
SBObject.hReturns an instance of an SBObject subclass initialized with the specified properties and data and added to the designated element array.
- (id)initWithElementCode:(DescType)code properties:(NSDictionary *)properties data:(id)data
A four-character code used to identify an element in the target application’s scripting interface. See Apple Event Manager Reference for details.
A dictionary with keys specifying the names of properties (that is, attributes or to-one relationships) and the values for those properties. Pass nil if you are initializing the object by data only.
An object containing data for the new SBObject object. The data varies according to the type of scripting object to be created. Pass nil if you initializing the object by properties only.
An SBObject object or nil if the object could not be initialized.
Unlike the other initializers of this class, this method not only initializes the SBObject object but adds it to a specified element array. This method is the designated initializer.
SBObject.hReturns an instance of an SBObject subclass initialized with the specified properties.
- (id)initWithProperties:(NSDictionary *)properties
A dictionary with keys specifying the names of properties (that is, attributes or to-one relationships) and the values for those properties.
An SBObject object or nil if the object could not be initialized.
Scripting Bridge does not actually create an object in the target application until you add the object returned from this method to an element array (SBElementArray).
SBObject.hReturns an object of the designated scripting class representing the specified property of the receiver
- (SBObject *)propertyWithClass:(Class)class code:(AEKeyword)code
The SBObject subclass with which to instantiate the object.
A four-character code that uniquely identifies a property of the receiver.
An instance of the designated class that represents the receiver’s property identified by code.
SBObject subclasses use this method to implement application-specific property accessor methods. You should not need to call this method directly.
SBObject.hReturns an object representing the specified property of the receiver.
- (SBObject *)propertyWithCode:(AEKeyword)code
A four-character code that uniquely identifies a property of the receiver.
An object representing the receiver’s property as identified by code.
SBObject subclasses use this method to implement application-specific property accessor methods. You should not need to call this method directly.
SBObject.hSends an Apple event with the given event class, event ID, and format to the target application.
- (id)sendEvent:(AEEventClass)eventClass id:(AEEventID)eventID parameters:(DescType)firstParamCode,...
The event class of the Apple event to be sent.
The event ID of the Apple event to be sent.
A list of four-character parameter codes (DescType) and object values (id) terminated by a zero.
The target application's Apple event sent in reply; it is converted to a Cocoa object of an appropriate type.
Scripting Bridge uses this method to communicate with target applications. If the target application responds to this method by sending an Apple event representing an error, the receiver calls its delegate's eventDidFail:withError: method. If no delegate has been assigned, the receiver raises an exception.
You should rarely have to call this method directly.
SBObject.hSets the receiver to a specified value.
- (void)setTo:(id)value
The data the receiver should be set to. It can be an NSString, NSNumber, NSArray, SBObject, or any other type of object supported by the Scripting Bridge framework.
You should not call this method directly.
SBObject.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-05-29)