AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Macdown insert registered trademark sign4/29/2023 ![]() ![]() This works in Objective-C because it's kind of a cheat this line: id markdownSource = (id)document ĭoesn't actually do a runtime cast it just tells the compiler to treat the pointer to the object as if it conforms to that protocol so that when you call its properties/methods it can do better type-checking of the arguments/return values. Is there a way to coax Swift into letting me do this? In the MacDown source, MPDocument inherits from NSDocument and has no protocol conformances. Then I tried putting the Objective-C protocol declaration in the bridging header, which compiles, but has nearly the same SIGABRT error: Could not cast value of type 'NSKVONotifying_MPDocument' (0圆00000ab6fd0) to 'MacDownMarkdownSource' (0x107ae00d0). ![]() If I remove the attributes, it dies with Swift runtime failure: type cast failed (although that shows up in Xcode's source editor, not as a message logged to the console. Let doc = dc.currentDocument as! MacDownMarkdownSourceīut it SIGABRTs with this message logged to the console: Could not cast value of type 'NSKVONotifying_MPDocument' (0圆00000df8c60) to 'MacDownInsertDatePlugin.MacDownMarkdownSource' (0x111ea90c8). ![]() I tried to do something similar: : var markdown : String Instead, you access application state by declaring your a protocol and casting from a singleton to that: MacDownMarkdownSource (readonly) NSString *dc = Theirs is written in Objective-C, but they don’t provide a header. I'm working on a MacDown plug-in, based off some sample code I found. ![]()
0 Comments
Read More
Leave a Reply. |