NSInvocationOperation Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in iOS 2.0 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.
Instance Methods
initWithInvocation:
Returns an NSInvocationOperation object initialized with the specified invocation object.
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
- Available in iOS 2.0 and later.
Declared In
NSOperation.hinitWithTarget:selector:object:
Returns an NSInvocationOperation object initialized with the specified target and selector.
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 must be
id. The return type of the method may bevoid, a scalar value, or an object that can be returned as anidtype.- 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.
Discussion
If you specify a selector with a non-void return type, you can get the return value by calling the result method after the operation finishes executing. The receiver tells the invocation object to retain its arguments.
Availability
- Available in iOS 2.0 and later.
Declared In
NSOperation.hinvocation
Returns the receiver’s invocation object.
Return Value
The invocation object identifying the target object, selector, and parameters to use to execute the operation’s task.
Availability
- Available in iOS 2.0 and later.
Declared In
NSOperation.hresult
Returns the result of the invocation or method.
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
- Available in iOS 2.0 and later.
Declared In
NSOperation.hConstants
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
NSInvocationOperationVoidResultExceptionThe name of the exception raised if the
resultmethod is called for an invocation method with avoidreturn type.Available in iOS 2.0 and later.
Declared in
NSOperation.h.NSInvocationOperationCancelledExceptionThe name of the exception raised if the
resultmethod is called after the operation was cancelled.Available in iOS 2.0 and later.
Declared in
NSOperation.h.
Declared In
NSOperation.h© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-08-19)