Hello Swift Users,
This is a Swift3 newbie question that I’ve not found a solution to. Has
there been any consensus reached on an equivalent approach to the AppKit class
NSInvocation ? Here’s a simple objC example.
-(NSInteger)totalCount
{
NSInteger totalCount = -1;
if ([self.representedObject respondsToSelector:@selector(totalCount)])
{
SEL selector = @selector(totalCount);
NSMethodSignature *aSignature = [[self.representedObject class]
instanceMethodSignatureForSelector:selector];
if (aSignature != nil)
{
NSInvocation *anInvocation = [NSInvocation
invocationWithMethodSignature:aSignature];
[anInvocation setSelector:selector];
[anInvocation setTarget:self.representedObject];
[anInvocation invoke];
[anInvocation getReturnValue:&totalCount];
}
}
return totalCount;
}
Thanks and regards,
RFM
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users