Questions tagged [nsinvocation]

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.

Resource

154 questions
4
votes
1 answer

Using block expectations with OCMock

I am using GHUnit & OCMock to do some testing work in my iOS app. So I have some trouble integrating them. The following code works well. NSString *s = [NSString stringWithString:@"122"]; id mock = [OCMockObject partialMockForObject:s]; [[[mock…
4
votes
2 answers

Determine if (void *) pointer from NSInvocation getArgument is object or primitive

Struggling with this one. Hoping it's possible and I don't sound silly. I'm hacking forwardInvocation in a class I'm writing. What I want to do is forward the invocation to one selector or another depending on if it is an object or primitive type.…
Erik Kerber
  • 5,646
  • 7
  • 38
  • 56
4
votes
1 answer

Found an NSZombie in my app... now what?

I have a subclass of NSManagedObject with a few "integer 32" attributes that are really enums. These enums are defined in my model's .h file like this: typedef enum { AMOwningCompanyACME, AMOwningCompanyABC, AMOwningCompanyOther }…
Shinigami
  • 2,123
  • 23
  • 40
4
votes
0 answers

NSInvocation getArgument:atIndex: confusion while testing blocks with OCMock

I'm writing unit tests to my Facebook SDK wrapper and something got me confused about NSInvocation's - (void)getArgument:(void *)buffer atIndex:(NSInteger)index while trying to mock FBRequest with OCMock. Here's the method definition I'm trying to…
Kaan Dedeoglu
  • 14,765
  • 5
  • 40
  • 41
3
votes
5 answers

Why does NSInvocation getReturnValue: lose object?

I need your help. I have some problems with NSInvocation 'getReturnValue:' method. I want to create UIButton programmatically, and even more, I want to create it dynamically using NSInvocation and through passing value through the NSArray (that's…
Alexander
  • 1,228
  • 2
  • 15
  • 29
3
votes
2 answers

NSValue:getValue: strange behavior,why this happens?

I try to pass CGRect to NSInvocation (setArgument:atIndex:). I wrap it by NSValue, push to the NSArry,then get from NSArray and use NSValue (getValue:). Calling of (getValue:) method causes the changing of before declared index NSInteger i. Can…
Alexander
  • 1,228
  • 2
  • 15
  • 29
3
votes
2 answers

How to remove/cancel NSInvocationOperation from NSOperationQueue?

Both of the following questions are being asked in context to maintain NSOperationQueue and NSInvocationOperation. As I have used this concept to download multiple videos, how do I remove/release added NSInvocationOperation from NSOperationQueue…
alloc_iNit
  • 5,173
  • 2
  • 26
  • 54
3
votes
2 answers

How to properly release retained arguments of an NSInvocation?

Are the retained arguments released when the NSInvocation is deallocated, or do I need to do a release manually on the objects in the argument list of an NSInvocation?
blueether
  • 3,666
  • 4
  • 26
  • 32
3
votes
1 answer

How can I get an NSString result from an NSInvocation?

The following code works as expected: NSLog(@"%@", [NSString stringWithString:@"test"]; // Logs "test" But when I replace it with an NSInvocation, I get a totally different result: Class class = [NSString class]; SEL selector =…
Hilton Campbell
  • 6,065
  • 3
  • 47
  • 79
3
votes
1 answer

NSInvocation: unrecognized selector though it is set

I'm getting this message: "(null): unrecognized selector sent to class 0x3f52e824" The basic code I've tried: SEL sel = @selector(applyProperties:toObject:); NSInvocation* inv = [NSInvocation invocationWithMethodSignature:[self…
michael
  • 2,332
  • 2
  • 21
  • 27
3
votes
2 answers

Calling a block though runtime, anything similar to NSInvocation?

I have block of unknown type (as id) and array of arguments that need to passed into that block. Arguments may be objects or numbers/structs boxed as NSNumber/NSValue. Block may also return an object, number or struct. This is a library code, and…
3
votes
2 answers

What is the difference between methodSignatureForSelector and instanceMethodSignatureForSelector?

It seems like instanceMethodSignatureForSelector is a class method, while methodSignatureForSelector is an instance method. However, their description and use cases do not bring me to this conclusion. So what is the difference?
user5084418
3
votes
0 answers

Dynamically call a function in Swift

I’m trying to implement a router pattern in Swift and can’t figure out how to dynamically call a method. For example, there’s an array of arguments: let arguments: [Any] = [100, 0.5, "Test"] And a handler which needs to be called: public class…
Zmey
  • 2,304
  • 1
  • 24
  • 40
3
votes
5 answers

EXC_BAD_ACCESS crash on arm64 when use NSInvocation

I've begun prepare one old project to support arm64 architecture. But when I try to execute this code on 64 bit device I get EXC_BAD_ACCESS crash on [invocation retainArguments]; line - (void)makeObjectsPerformSelector: (SEL)selector withArguments:…
abagmut
  • 911
  • 1
  • 10
  • 22
3
votes
1 answer

Why NSInvocation

Why use NSInvocation when you could just call the method? Need to ask this question because I can't understand the need to use this class. What is the advantage of using it over just calling the method like below. [myArray…
naz
  • 1,478
  • 2
  • 21
  • 32
1 2
3
10 11