Theocacao
Leopard
Design Element
Comment on "Dynamic Objective-C with NSInvocation"
by Dalmazio Brisinda — Oct 27
Great article.

I was wondering if this would also work for invoking class methods on a class object? For example if +stringForDate:usingFormatter: was a class method instead of an instance method:

SEL mySelector; mySelector = @selector(stringForDate:usingFormatter:); NSMethodSignature * sig = nil; sig = [self methodSignatureForSelector:mySelector]; NSInvocation * myInvocation = nil; myInvocation = [NSInvocation invocationWithMethodSignature:sig]; [myInvocation setTarget:[self class]]; // <-- will this work? [myInvocation setSelector:mySelector];

and the rest given as above?

Best,
Dalmazio
Back to "Dynamic Objective-C with NSInvocation"
Design Element

Copyright © Scott Stevenson 2004-2015