[swift-users] NSInvocation equivalent

Kwame Bryan kwame.bryan at gmail.com
Wed Oct 5 18:30:44 CDT 2016


If you could define your needs. Is it a one to one ? Or one to many
relationship. I would look into the Observer Design pattern.

On Oct 5, 2016 7:26 PM, "Jordan Rose via swift-users" <swift-users at swift.org>
wrote:

>
> > On Oct 5, 2016, at 14:43, Jens Alfke via swift-users <
> swift-users at swift.org> wrote:
> >
> >
> >> On Oct 5, 2016, at 1:50 PM, Bob Miller via swift-users <
> swift-users at swift.org> wrote:
> >>
> >>      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.
> >
> > Swift doesn’t have an equivalent because the language simply isn’t as
> dynamic as Objective-C: there is no mechanism to invoke a method at runtime
> given its name.
> >
> > If you’re on an Apple platform, and the method you want to call, and its
> class, are @objc — then you can literally use NSInvocation from Swift to do
> this. But not otherwise.
>
> However, there are usually better answers than NSInvocation (both in Swift
> and Objective-C). What are you actually trying to do?
>
> Jordan
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161005/d658d33f/attachment.html>


More information about the swift-users mailing list