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
1
vote
1 answer

ios invoke block target with copy method,but crashed

I use invocation call block copy, I think it's equals to [block copy],but crashed why? @implementation MyService + (void)load { [MyService startRequest:^(id _Nonnull responseObject, NSError * _Nonnull error) { …
Y Robin
  • 80
  • 1
  • 6
1
vote
3 answers

Objective C - NSInvocation passing self as sender?

I am trying to use NSInvocation to call a method on an object and send the sender as an argument. The code below calls the mthod but it seems like the object is passing to the mthod is not really self object - (void)setTarget:(id)taret…
aryaxt
  • 76,198
  • 92
  • 293
  • 442
1
vote
1 answer

Passing a delegate around in iOS

I'm developing an iOS app which includes a search form. When a user clicks search, I want to use an NSInvocationOperation (which is fine) to spawn another thread. On this thread, I'll call my data layer (a separate class) to retrieve data from a web…
Echilon
  • 10,064
  • 33
  • 131
  • 217
1
vote
0 answers

NSInvocation whith multiple arguments not working in Action Extension in iOS 13.0 beta

I used this code for open settings threw my App Action Extension. It works in iOS 12.0 but in iOS 13.0 it crashes. NSURL *shareURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; // SEL selector =…
Hector
  • 3,909
  • 2
  • 30
  • 46
1
vote
1 answer

Why NSInvocation return value creates a zombie?

I am trying to build a JavaScript to Native communication. For that purpose I need to execute dynamically a method on some class when JavaScript calls it. I have a problem with NSInvocation getting the return value. When the getReturnValue is used…
h3dkandi
  • 1,106
  • 1
  • 12
  • 27
1
vote
2 answers

How to encode a NSInvocation?

Can I fix this with adding a category of methods ?
Kristof
  • 557
  • 6
  • 14
1
vote
1 answer

NSInvocation; variable is not a CFString

I'm making a dynamic call using NSInvocation: NSInvocation *lNSInvocation = [NSInvocation invocationWithMethodSignature: [lListener methodSignatureForSelector:lSelector]]; [lNSInvocation setTarget:lListener]; [lNSInvocation…
Tbee
  • 450
  • 4
  • 8
1
vote
1 answer

Apple's caution in its documentation of + (NSMethodSignature *)signatureWithObjCTypes:(const char *)types

In Apple's documentation of this method, it says the following at the end: Special Considerations This method, available since Mac OS X v10.0, is exposed in Mac OS X v10.5. Only type encoding strings of the style of the runtime that the application…
William Jockusch
  • 26,513
  • 49
  • 182
  • 323
1
vote
1 answer

Do static objective-c classes have to subclass NSObject?

In my objective-c project, I have a weird, lets say, feature I have a class, like this: #import @interface Convert /* : NSObject */ // <--- is that necessary? +(int) toInt:(id) obj; @end @implementation Convert +(int)…
Richard J. Ross III
  • 55,009
  • 24
  • 135
  • 201
1
vote
1 answer

Step into -[NSInvocation invoke] during debugging

When debugging Objective-C code, lldb skips calls to objc_msgSend and stops in the actual method being called. I'd like to have similar behavior when debugging some code that uses NSInvocation. When reaching the point where -[NSInvocation invoke] is…
kjam
  • 809
  • 1
  • 7
  • 17
1
vote
1 answer

NSMethodSignature & NSInvocation equivalent in swift 2

How can i writte this class in swift 2 ? NSMethodSignature & NSInvocation doesn't exist anymore in swift 2 @implementation MyAuth - (void)authorizeRequest:(NSMutableURLRequest *)request delegate:(id)delegate …
YouSS
  • 560
  • 7
  • 20
1
vote
1 answer

NSInvocation with value type arguments

Is it possible to use NSInvocation with value type arguments? Currently we can do this: [invocation setArgument:¶m1 atIndex:2]; But we'd like that first parameter to be a value type such as int. When I look at the variable being passed to the…
Gaurav Sharma
  • 2,680
  • 3
  • 26
  • 36
1
vote
1 answer

static method NSInvocation

Is it possible to use NSInvocation for static method calls? We're using NSInvocation to simplify our method calls in unit tests for non-public methods. This works great for our instance methods, for which we provide an object and appropriate data…
Gaurav Sharma
  • 2,680
  • 3
  • 26
  • 36
1
vote
2 answers

Why the action triggered by a NSTimer can't be specified by a block?

When creating a timer, there are only these options: + (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds target:(id)target selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)repeats; + (NSTimer…
Lay González
  • 2,901
  • 21
  • 41
1
vote
1 answer

iOS: Class method added by class_addMethod can't be used by NSInvocation

I add a class method to a class using runtime feature, but this method can't be used by NSInvocation. My code is as this: id metaClass = object_getClass((id)protocolClass); IMP prevImp = class_replaceMethod(metaClass, @selector(xxx), imp,…
keywind
  • 1,135
  • 14
  • 24