How does one use namespaces in iOS objective-c code?

前端 未结 2 1776
终归单人心
终归单人心 2021-01-11 10:38

I\'m writing an iOS app, \"Best Korea\". My organization name is \"Srsly.co\". I\'m going to write re-usable \"News\" libraries that I\'ll use across my apps.

Each

相关标签:
2条回答
  • 2021-01-11 10:43

    There is no NameSpace in Objective-C as you are expecting in Java.

    Objective-C uses class Prefix like NS, UI, CG, CF etc to safely remove name space collision.

    And it would be better to use 3 letter Prefix for your class.

    You should read this : What is the best way to solve an Objective-C namespace collision?

    0 讨论(0)
  • 2021-01-11 10:52

    You're correct that Objective-C doesn't have built in support for namespaces, and the common solution is to use uppercase prefixes on each class. Note that Apple has stated that two letter prefixes are reserved for their use, so you should use three letter prefixes for your own classes. Otherwise, your suggested approach is the normal thing to do.

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