Saagar Jha > On Feb 6, 2017, at 10:57 PM, Andrew Trick <atr...@apple.com> wrote: > > >> On Feb 6, 2017, at 8:51 PM, Dave Abrahams <dabrah...@apple.com> wrote: >> >> >> on Mon Feb 06 2017, Andrew Trick <atrick-AT-apple.com> wrote: >> >>> Is a missing declaration a use case that needs to be supported? >> >> I couldn't say. >> >>> Wouldn’t it be more proper to use selector based dispatch in those >>> cases? >> >> Example, please? I don't know what that means, though I probably should. >> >> -- >> -Dave > > I phrased that as a question because I'm the last person who should be giving > advice here... What I had in mind is this: > > if ([self isKindOfClass:NSClassFromString(@“Bar”)]) { > self.perform(@selector(FakeBarProtocol.foo)) > } > > It's not type safe, but it's a lot better than outright lying about the > reference's dynamic type. > > Of course, the root problem is that Bar's declaration is unavailable, and > that's not a normal, expected thing.
Yep, it’s not–that’s why I need to go through this trouble :) My plugin is loaded at runtime, so the headers are the best I’ve got (though if you’ve got a way to perform a stricter check, I’m all ears!) Until then, all of these methods appear to be sugarcoating around perform(selector:)–is there any “preferred” way to do this? Also, class_getName(_:) seems to return a UnsafePointer<Int8>, is this just a C-style string? Should I use this over NSStringFromClass or isKindOfClass? > > -Andy >
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users