Swift reflection Mechanism, namespace

Source: Internet
Author: User

1. Know that there is a namespace in Swift
-Share globally under the same namespace!
-third-party framework using Swift if you drag directly into the project, dependent on the same namespace, there is a good chance of conflict!
-Try to use cocoapod later
2, the focus is to know how Swift nsclassfromstring (launch mechanism) of the wording
-The most important purpose of the launch is decoupling
-Tip: First impressions will find a simple function that is very complex to write. But the package is good, the elasticity is very big!

In a program, you need a namespace when you need to use string to get the class name

Let Clsname = Bundle.main.infoDictionary? ["cfbundlename"as"" ". " " Viewcontroller "  as? Uiviewcontroller.type

So that we can get the right Viewcontroller .

Swift reflection Mechanism, namespace

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.