Objective C Pros:

  • can support C++ library

  • weak typed language, differences, 可以不同类型一起运算

  • sending nil to object will not crash the app

  • has macro

Objective C Cons:

  • no namespace

  • Swift provides more powerful collection types, array, set, dictionary.

  • Swift also provides some advanced data type : Tuples.

  • swift introduce 可选类型(Optionals),用于处理变量值不存在的情况。to represent the instance is not existed or invalid

    • 可选项的意思有两种:一是变量是存在的,例如等于X,二是变量值根本不存在。
    • Optionals similiar with Objective-C中指向nil的指针,但是适用于所有的数据类型,而非仅仅局限于类
    • Optionals 相比于Objective-C中nil指针更加安全和简明,并且也是Swift诸多最强大功能的核心。
    • more safe and elegant with Swift syntax sugar, only add a "question mark" to use

results matching ""

    No results matching ""