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
45
votes
14 answers
Objective-C: How to call performSelector with a BOOL typed parameter?
Is there any way to send a BOOL in selector ?
[self performSelector:@selector(doSomething:) withObject:YES afterDelay:1.5];
Or I should use NSInvocation? Could somebody write a sample please ?

Jim
- 8,874
- 16
- 68
- 125
26
votes
3 answers
NSInvocation returns value but makes app crash with EXC_BAD_ACCESS
I have an array which I am iterating and looking for a particular flag. If the flag value is nil, I am calling a method which generates an invocation object and returns the result of invocation.
My code structure is as follows
for(NSString *key in…

slysid
- 5,236
- 7
- 36
- 59
19
votes
2 answers
forwardInvocation not being called?
I'm having trouble getting forwardInvocation to work. For some reason, the Objective-C runtime completely ignores my forwardInvocation: method and throws an unrecognized selector exception.
My test code is as follows:
@interface InvocationTest :…

Karl
- 14,434
- 9
- 44
- 61
19
votes
3 answers
Difference between Dispatch Queue and NSOperationQueue
I am very new to GCD and threading. I have gone through the tutorials and getting very much confusion.
Can some one explain in simple words.Please don't suggest apple developer links..
Thanks in advance !

Youngwing
- 577
- 2
- 6
- 24
15
votes
4 answers
-[NSInvocation getReturnValue:] with double value produces 0 unexpectedly
I am trying to call a method that returns a double using NSInvocation. But I found that it does not working in 64 bit iOS apps. It works on on OS X, in the simulator -- both 32-bit and 64 bit -- iPad 2, and iPad Air with a 32-bit build. Only the…

Bryan Chen
- 45,816
- 18
- 112
- 143
14
votes
3 answers
Asynchronous NSURLConnection with NSOperation
I want to do NSURLConnection in background mode,because it response is having much data.Forums are telling to use Apple's finite length coding to use in didEnterBackground.
but I want to avoid it.instead of it I use following code through…

nameless
- 809
- 3
- 9
- 27
13
votes
1 answer
Get block argument from NSInvocation with ARC
I'm trying to get the block argument from the NSInvocation in NSProxy's forwardInvocation:
Is this the correct syntax? Would it leak memory?
typedef void(^SuccessBlock)(id object);
void *successBlockPointer;
[invocation…

pshah
- 2,052
- 1
- 21
- 40
13
votes
3 answers
Defining an Objective-C Class without a base Class - Compiler Warning
I'm using the Following NSInvocation code form Matt Gallagher for my Undo/Redo code. Though with the Latest version of xCode I'm not getting a Warning that says:
NSInvocation(ForwardedConstruction).m:28:12: Class 'InvocationProxy' defined without…

scooter133
- 1,297
- 1
- 15
- 29
10
votes
3 answers
What's the purpose of the setSelector method on the NSInvocation class?
I don't understand why we have to call the setSelector method on NSInvocation objects when that information is already passed via the invocationWithMethodSignature.
To create an NSInvocation object we do the following:
SEL…

haroldcampbell
- 1,512
- 1
- 14
- 22
10
votes
7 answers
Make NSInvocation invoke a specific IMP
I'm looking for a way to make an NSInvocation invoke a specific IMP. By default, it invokes the "lowest" IMP it can find (ie, the most-recently-overridden version), but I'm looking for a way to make it invoke an IMP from higher up in the…

Dave DeLong
- 242,470
- 58
- 448
- 498
9
votes
2 answers
NSInvocation and ARC (Automatic Reference Counting)
When trying to migrate my current code to ARC, I'm getting errors whenever I pass an NSString as an NSInvocation argument.
Example:
NSInvocation inv = ...;
NSString *one = @"Hello World!";
[inv setArgument:&one atIndex:2];
The error happens when I…

Anonymous
- 1,750
- 3
- 16
- 21
9
votes
1 answer
Swift: overriding an initializer that takes an NSInvocation
I'm trying to create a reusable test harness in Swift with the idea that subclasses will extend the test harness to provide the instance under test, and can add their own subclass-specific test methods, something like this:
class FooTestHarness:…

David Moles
- 48,006
- 27
- 136
- 235
8
votes
2 answers
Is there any alternative for NSInvocation in Swift?
I'm trying to invoke a selector, with multiple (2+) arguments (the number of arguments can be determined). However, the selector is unknown at compile time (generated with NSSelectorFromString, actually).
In Objective-C, I could create an invocation…

Aswath
- 1,236
- 1
- 14
- 28
8
votes
2 answers
NSInvocation and memory issues
So I come from the Java world where we are blissfully ignorant of memory management issues. For the most part, ARC has saved my butt, but here is something that has got me stumped. Basically I am using NSInvocations for some stuff, and I ran into…

user2453876
- 303
- 2
- 12
7
votes
1 answer
NSInvocation with block arguments
I'm trying to pass block arguments to a NSInvocation, but the app crashes. The invocation makes a network request and calls the success or failure blocks. I think the problem is that blocks are dealloced before the network request finishes. I…

pshah
- 2,052
- 1
- 21
- 40