An NSInvocation object contains all the elements of an Objective-C message: a target, a selector, arguments, and the return value. Each of these elements can be set directly, and the return value is set automatically when the NSInvocation object is dispatched.
Questions tagged [nsinvocation]
154 questions
3
votes
1 answer
Why does this NSInvocation raise an exception?
I have a real head-scratcher right now. So, an NSTimer object, an NSMethodSignature object, and an NSInvocation object walk into a bar. Here's the rest of the joke:
NSMethodSignature *methodSig = [NSMethodSignature…

Ben Stock
- 1,986
- 1
- 22
- 30
3
votes
1 answer
How to pass an array to an objc method that expects var args (eg ...')
I have a method in a library that looks like so:
- (id)initWithSomeObjects:(NSString *)something, ... NS_REQUIRES_NIL_TERMINATION;
I'd really like to call it with an array instead of var args, because the number of objects i'd like to pass in is…

Chris
- 39,719
- 45
- 189
- 235
3
votes
1 answer
Passing blocks to asynchronous methods
I'm passing a block to an asynchronous method which executes this block later. My app crashes if I don't copy the block before passing it to someMethod:success:failure:
Is there a way to copy the blocks in forwardInvocation: instead of copying it…

pshah
- 2,052
- 1
- 21
- 40
3
votes
1 answer
How to use NSInvocation to call a class method?
I've a class method which is not declared in the h file, but implemented in the m file.
now I want to call it in another class, since the return value is a int, I can't use selector directly, so I use NSInvocation.
below is what i'm doing:
SEL…

Jerrylk
- 379
- 5
- 19
3
votes
1 answer
Strange "zombie" in forwardInvocation: + getArgument:atIndex methods
Here is part from my code:
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect frame = [[UIScreen mainScreen] bounds];
_webView = [[UIWebView alloc] initWithFrame:frame];
[_webView setHidden:NO];
[self.view addSubview:_webView];
…

AndrewShmig
- 4,843
- 6
- 39
- 68
3
votes
2 answers
Is there a way to observe every message calls invoked on an object (iOS)?
I just want to get a selector name, and the arguments, sender, or an NSInvocation instance every time when I send a message to an object. Possible? Something like forwardInvocation:, but in evey case (every method call).

Geri Borbás
- 15,810
- 18
- 109
- 172
2
votes
2 answers
How to perform UIKit call on mainthread from inside a block
I am trying to push a view controller from inside a callback block. The view controller I want to push contains a UIWebView, which complains that I should call this on the main thread. I tried using NSInvocation to no avail. How can I call…

Morrowless
- 6,856
- 11
- 51
- 81
2
votes
3 answers
NSInvocation pass C-arrays to Objective-C method
I want to pass C-arrays to a method in Objective-C after a delay. Typically I could performSelector:withObject:afterDelay but I can't change the arrays in any way or convert them to NSMutableArrays, NSDictionaries or any other Cocoa object - they…

PhilBot
- 748
- 18
- 85
- 173
2
votes
4 answers
A nice way to perform a selector on the main thread with two parameters?
I'm searching for a nice way to perform a selector on the main thread with two parameters
I really like using
- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait
method, except now I have two…

dariaa
- 6,285
- 4
- 42
- 58
2
votes
1 answer
Accessing forwardInvocation'd methods with ARC?
I'm writing a clone of OpenStruct in Objective-C, using forwardInvocation:. However, the compiler isn't aware of the forwarding at compile time apparently. Compiling with ARC gives me a ton of warnings.
The code is open source and available on…

wjl
- 7,143
- 1
- 30
- 49
2
votes
1 answer
Construct NSInvocation w/ Block argument
I'm trying to send a Block as an argument to a method called by an NSInvocation (which, for context, is fired by an NSInvocationOperation). The invocation should be retaining the arguments, and it seems to be working for the "regular" object…

Ben Mosher
- 13,251
- 7
- 69
- 80
2
votes
2 answers
NSInvocationOperation define selector with params
I am trying to create NSInvocationOperation so that it should call object's method with params
- (void) getImages: (NSRange) bounds
{
NSOperationQueue *queue = [NSOperationQueue new];
NSArray * params = [NSArray arrayWithObjects:
…

duganets
- 1,853
- 5
- 20
- 31
2
votes
1 answer
releasing NSInvocationOperation causes app to crash
Hi I have the following code
NSString *analyticsStr = [[NSString alloc] initWithString:[self constructXMLMessage:TagObj]];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
…

Asad Khan
- 11,469
- 13
- 44
- 59
2
votes
2 answers
Check if on ObjC selector (SEL) has a parameter
Just like UIButton where I can:
[button addTarget:target forSelector:@selector(action)]
Or:
[button addTarget:target forSelector:@selector(action:)]
Where in the second one the action for the button will have a sender (being the button itself),…

Heuristic
- 5,087
- 9
- 54
- 94
2
votes
1 answer
NSInvocation not passing pointer to c++ array
I think I'm making just a fundamental mistake, but I cannot for the life of me see it.
I'm calling a method on an Objective-C object from within a C++ class (which is locked). I'm using NSInvocation to prevent me from having to write hundreds…

Stephen Furlani
- 6,794
- 4
- 31
- 60