Is it possible to write inline assembly in Swift?

前端 未结 2 1560
粉色の甜心
粉色の甜心 2020-12-10 02:11

I was wondering if you can write inline assembly in Swift.

I know that in Objective-C you could use something like this:

inline void assemblyFunc() {         


        
相关标签:
2条回答
  • 2020-12-10 02:36

    To expand on what Robert Levy said, you can just use the Swift/Obj-C interop feature, and write an Obj-C class that does the ASM stuff, which you can then call from Swift.

    It's an annoying workaround, but it should work nonetheless.

    You can read more about how to do it [here]

    0 讨论(0)
  • 2020-12-10 02:44

    There isn't a way in Swift itself. If you need this, probably a good opportunity to take advantage of Swift-ObjC interop.

    0 讨论(0)
提交回复
热议问题