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
1
vote
2 answers
Why would I use an NSInvocation instead of a Block?
Can someone offer a concrete reason for using an NSInvocation instead of just using a Block, or even a regular method call? I am finding descriptions of NSInvocation around the Web, but no examples of where it is vital to use or even the only good…

user255468
- 33
- 1
- 7
1
vote
1 answer
Get the sender of the message for an NSInvocation
How do I get the sender of the message wrapped in an `NSInvocation?
I'm in an object, and I've just received an invocation in my forwardInvocation:.
Is there any way to know who sent me the message in the first place?

unom
- 11,438
- 4
- 34
- 54
1
vote
1 answer
How to create instance of my own class using NSInvocation?
I am trying to create a new instance of my custom class (custom init method call, with a BOOL parameter) dynamically. How can I use NSInvocation to do that?
This is what I have so far:
NSMethodSignature* signature = [NSClassFromString(className)…

user516542
- 107
- 2
- 8
1
vote
1 answer
Over-riding NSObject and adding a class variable
I am using the following code to perform a selector after a delay with multiple passed parameters:
http://nifty-box.com/blog/2006/12/nsinvocation-cleans-code.html
It works very well, but I need to extend this to support the equivalent of:
[NSObject…

Jeffrey Berthiaume
- 4,054
- 3
- 35
- 45
1
vote
1 answer
Multicast Block: How to generalize
Goal
I have a class with various properties that can be used to plug in a block to receive certain events.
@interface SomeClass
@property (copy, nonatomic) void (^handler)(int arg1, int arg2);
@end
In the client code, I would like to dynamically…

Etan
- 17,014
- 17
- 89
- 148
1
vote
2 answers
NSTimer + NSInvocation causing crash on iOS 7
I'm running into a crash when using +[NSTimer scheduledTimerWithTimeInterval:invocation:repeats] on iOS 7. The code is straightforward enough; here is the copy paste (with variable renames) in its entirety.
SEL selector =…

Dan Loewenherz
- 10,879
- 7
- 50
- 81
1
vote
1 answer
CGRect gets corrupted when passed up the stack
I have these 4 lines of code inside a function
void * someFunction() {
... code to create invocation and other things
CGRect aRect;
[invocation getReturnValue:&aRect];
finalValue = &aRect;
return…

LombaX
- 17,265
- 5
- 52
- 77
1
vote
1 answer
IOS NSMethodSignature stays nil
I recently started to develop for IOS and struggle with the Invocation Object.
What i have is a Class "Location", derived from NSManagedObject (it's part of the Coredata model)
@interface Location (CoreDataGeneratedAccessors)
-…

billdoor
- 1,999
- 4
- 28
- 54
1
vote
1 answer
NSTimer never fires
I've been having problems getting an NSTimer to fire, and I assumed it had to with multi-threading issues. Just to be sure I was creating the timer correctly, I created the following test code and I placed it into my main view controller's…

Regan
- 1,487
- 2
- 28
- 43
1
vote
1 answer
NSTimer and NSInvocation, timer does not fire
First I create an NSInvocation, because the method I want to call with the timer has several parameters, which I set here
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[self…

Regan
- 1,487
- 2
- 28
- 43
1
vote
1 answer
Mulptiple alloc of NSOperationQueue crashes my app
I update my tableview by loading json result from server using NSOperationQueue
Adding queue:
- (void)AddQueue
{
NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc]…

Pavel Kaljunen
- 1,291
- 2
- 26
- 53
1
vote
1 answer
Get the results returned from an NSInvocationOperation
- (void)viewDidLoad
{
NSOperationQueue *operationQueue = [[NSOperationQueue alloc]init];
NSInvocationOperation *downloadImageOperation = [[NSInvocationOperation alloc] initWithTarget:[ImageDownloader getInstance]
…

pvllnspk
- 5,667
- 12
- 59
- 97
1
vote
0 answers
Custom button for cocos2d
I was working on creating my custom "Button" class... Im not using CCMenuItems because I need some flexibility in my buttons.
My implementation is the following:
DMenuButton : CCSprite
When created, the button receives a…

Diego
- 577
- 4
- 14
1
vote
1 answer
ARC [rewriter] NSInvocation's setArgument is not safe to be used with an object with ownership other than __unsafe_unretained
I been to convert my project to ARC and i m stuck with this error.
&object,&invocation and &callerToRetain is showing me error of "[rewriter] NSInvocation's setArgument is not safe to be used with an object with ownership other than…

Bulla
- 924
- 1
- 7
- 15
0
votes
2 answers
Passing a selector name as a method parameter
I'm writing a custom helper method that will get used a lot and return several buttons. Each button will of course have its own target selector when pressed, and I want to pass the selector as a parameter into this method so the returned button has…

johnbakers
- 24,158
- 24
- 130
- 258