JetForMe
(Rick M)
1
I'm trying to convert an old Obj-C project to Swift. I'm using an esoteric serialization protocol called Hessian that gets configured with calls like this:
[CWHessianUnarchiver setProtocol: @protocol(MissionProtocol) forClassName: @"com.some.java.server.class.ClientV1Mission"];
…
@protocol MissionProtocol
// Properties…
@end
In Swift, the calls look like this, but this isn’t quite right, and I'm not sure how to write it:
CWHessianUnarchiver.setProtocol(MissionProtocol.Type, forClassName: "com.some.java.server.class.ClientV1Mission")
But I get {Cannot convert value of type '(any MissionProtocol.Type).Type' to expected argument type 'Protocol?'" for the setProtocol call. How should I pass this?
bbrk24
2
Objective-C Protocol objects, like Swift metatypes, are spelled P.self, not P.Type.
3 Likes
Kyle-Ye
(Kyle)
3
The 2 posts may help solve your problem.
1 Like
JetForMe
(Rick M)
4
I tried that, but it didn't work. However, I just tried it again, and it works. I must've not tried. But now I'm questioning my sanity. Thanks!
2 Likes