Static library introduction, simple drills, conflict resolution with resources of the same name, static drills

Source: Internet
Author: User

Static library introduction, simple drills, conflict resolution with resources of the same name, static drills

1. Both static and dynamic libraries are closed source libraries and do not disclose source code.

Static Library:. a and. framework

Dynamic library:. dylib and. framework (iOS9 cancels. dylib and uses. tbd instead)

 

2. Differences between static and dynamic libraries:

Static Library: When linked, the files used in the static library will be completely copied to the executable file. When used multiple times, there will be multiple redundant copies.

Dynamic library: do not copy links. When the program is running, the system dynamically loads the resources to the memory for the program to call. The system only loads the resources once and multiple programs are shared, saving the memory.

Note: If a self-made dynamic library is used in the project, it cannot be uploaded to the AppStore.

Because: Dynamic Inventory is in the system and can be updated. You don't need to upload an AppStore (Apple doesn't make money). There is a high risk (injection attacks, impersonating system libraries, and passing values between Apps, because they all use the same thing ).

 

3. Create a static database:

 

4. Introduction to static library directories:

,

 

5. Create a project and import the static Library:

 

6. How to Use the imported static Library:

 

7. When adding a custom source file, you also need to manually add its header file. Similarly, you also need to manually import the added resource file:

 

Manual import:

 

Let's take a look at the generated file. We can see that the header file of the custom source file already exists:

 

8. Use the static library's image creation method and resource file to create images and display them:

 

9. Note that if the resource file in the project is the same as the resource file in the static library, the resource file in the project will be used:

 

10. How can I display resources in the static library:

Simple: Place resources in a Bundle package, add the Bundle package to the static library, and use "Step 7" to manually import the Bundle package, and then use the resource: "Bundle package/Resource Name.

 

Add resources to the Bundle package and drag the Bundle package into the project:

 

Manually import the Bundle package:

 

Generate static Library:

 

11. Use "Bundle package path/Resource Name" to reference the resource file of the static Library:

 

12. regenerate the static library file, import the file to the project, and call the static library code. You can see that the image created at this time is the image in the static library.

Related Article

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.