First, I would like to add that this series is not a tutorial. In addition to errors, this series will not be written in a simple order. What theme to write depends on your mood.
After C # is switched to Objective-c development, the following question occurs:
Does Objective-C seem to have no namespace?
Yes. C ++ and C # Have namespace and Java have Package (of course there is a difference with Namespace). php I recently wrote is also like namespace com \ example \ johnslibrary \ people; even JavaScript... Well let's forget JavaScript, it should have no built-in namespace (see http://elegantcode.com/2011/01/26/basic-javascript-part-8-namespaces/ and http://addyosmani.com/blog/essential-js-namespacing ).
When developing C #, you will often encounter classes with the same name under different namespaces. In this case, you can use alias to distinguish between them.
For example
using n1=Namespace1;using n2=Namespace2;n1.ClassA=new n1.ClassA();n2.ClassA=new n2.ClassA();
But Objective-C does not.
Similar to c, everything runs in the same global namespace.
Therefore, when creating an Objective-c application, there will be a text box for you to enter the prefix ).
"NS" is the prefix of built-in Cocoa, indicating NextStep. This prefix is occupied by Apple. The relationship between NextStep and Mac OS is not much said.
However, compared with general NameSpace names such as CompanyA. XXX. YYY, prefixes are prone to conflicts. If I start a company called MoeSoft, the prefix may conflict with Microsoft.
If the MoeSoft and Microsoft class libraries with the MS prefix are referenced at the same time, it may be a tragedy.
Stackoverflow provides the following solutions:
Use NSBundle to load one of the frameworks, copy and rename the framework, and then load another namespace.
Another suggestion is to use @ compatibility_alias to "RENAME" the class.
For details, see:
Http://stackoverflow.com/questions/178434/what-is-the-best-way-to-solve-an-objective-c-namespace-collision
If this problem can be avoided, try to avoid it. What are the idioms? The gentleman does not stand under the Dangerous wall.
So unless you are writing the simplest test code, you 'd better give your application a unique prefix long enough.