Is Swift a dynamic or static language?

前端 未结 4 547
生来不讨喜
生来不讨喜 2020-12-15 03:23

I\'m just curious if Swift is dynamic like php or static, I mean can I generate classes while an application is running?

4条回答
  •  死守一世寂寞
    2020-12-15 04:11

    Swift itself, is statically typed. When used with Cocoa, you get access to the objective-c runtime library which gives you the ability to use dynamic classes, messages and all. This doesn't mean the language itself is dynamically typed. You could do the same with C or any other language that supports a bridge to C by using libobjc.A.dylib.

提交回复
热议问题