Next Page > Hide TOC

NSInvocationOperation Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in Mac OS X v10.5 and later.
Companion guide
Declared in
NSOperation.h

Overview

The NSInvocationOperation class is a concrete subclass of NSOperation that manages the execution of a single encapsulated task specified as an invocation. You can use this class to initiate an operation that consists of invoking a selector on a specified object. This class implements a non-concurrent operation.

For more information on concurrent versus non-concurrent operations, see NSOperation Class Reference.

Tasks

Initialization

Getting Attributes

Instance Methods

initWithInvocation:

Returns an NSInvocationOperation object initialized with the specified invocation object.

- (id)initWithInvocation:(NSInvocation *)inv

Parameters
inv

The invocation object identifying the target object, selector, and parameter objects.

Return Value

An initialized NSInvocationOperation object or nil if the object could not be initialized.

Discussion

This method is the designated initializer. The receiver tells the invocation object to retain its arguments.

Availability
Declared In
NSOperation.h

initWithTarget:selector:object:

Returns an NSInvocationOperation object initialized with the specified target and selector.

- (id)initWithTarget:(id)target selector:(SEL)sel object:(id)arg

Parameters
target

The object defining the specified selector.

sel

The selector to invoke when running the operation. The selector may take 0 or 1 parameters. If it accepts a parameter, the type of that parameter should be id.

arg

The parameter object to pass to the selector. If the selector does not take an argument, specify nil.

Return Value

An initialized NSInvocationOperation object or nil if the target object does not implement the specified selector.

Availability
Declared In
NSOperation.h

invocation

Returns the receiver’s invocation object.

- (NSInvocation *)invocation

Return Value

The invocation object identifying the target object, selector, and parameters to use to execute the operation’s task.

Availability
See Also
Declared In
NSOperation.h

result

Returns the result of the invocation or method.

- (id)result

Return Value

The object returned by the method or an NSValue object containing the return value if it is not an object. If the method or invocation is not finished executing, this method returns nil.

Discussion

If an exception was raised during the execution of the method or invocation, this method raises that exception again. If the operation was cancelled or the invocation or method has a void return type, calling this method raises an exception; see “Result Exceptions”.

Availability
Declared In
NSOperation.h

Constants

Result Exceptions

Names of exceptions raised by NSInvocationOperation if there is an error when calling the result method.

extern NSString * const NSInvocationOperationVoidResultException;
extern NSString * const NSInvocationOperationCancelledException;

Constants
NSInvocationOperationVoidResultException

The name of the exception raised if the result method is called for an invocation method with a void return type.

Available in Mac OS X v10.5 and later.

Declared in NSOperation.h.

NSInvocationOperationCancelledException

The name of the exception raised if the result method is called after the operation was cancelled.

Available in Mac OS X v10.5 and later.

Declared in NSOperation.h.

Declared In
NSOperation.h

Next Page > Hide TOC


© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-04-12)


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.