Instance Method

initWithTarget:selector:object:

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

Declaration

- (instancetype)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 must be id. The return type of the method may be void, a scalar value, or an object that can be returned as an id type.

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.

See Also

Initialization

- initWithInvocation:

Returns an NSInvocationOperation object initialized with the specified invocation object.