IPhone static library learning notes

Source: Internet
Author: User

I. Basic Knowledge

In the actual programming process, some common functions are usually made into function libraries for use by other programs. One is to reuse the code, and the other is to keep the core technology confidential. Therefore, in actual project development, function libraries are often used. The function libraries are divided into static and dynamic libraries. Similar to the dynamic and static languages that most people are familiar with, static and dynamic languages are called relative to the compilation and runtime periods: static libraries are linked to the target code during program compilation, when the program is running, you no longer need to change the static library. When the program is compiled, the dynamic library is not linked to the target code. It is loaded only when the program is running, because the dynamic library is also required during the running of the program.

For the iPhone platform, the iPhone only supports static Library Association, so the following describes the usage of the static library in the iPhone.

Ii. iPhone static library usage

1. Create a static database

Open xcode to create a new project, select "cocoa touch static library" under the library, right-click the classes folder and choose "New File ...", Then select "objective-C Class" under "cocoa touch class" to create an objective-C style source file and header file.

Similarly, you can create C or C ++ code, right-click the classes folder, and select "New File ...", Select "C and C ++" under Mac OS X this time.

Then write the specific call code in the file.

After compilation, a file ending with. A is generated, which is the static library we need. At the same time, we also need to generate the. h header file.

2. Use a static library

Right-click frameworks> Add> existing files in the directory of the project where you want to call the static library .. add. A static library file, and then call the function of the static library. in the H file, import is in the static library. m. h header file, and declare the class in the static library: @ Class class name, so that you can use the function in the static library.

3. Joint debugging of static databases

If it is included in the file in copy mode. A static library. In this way, only the static library can be used. If you need to modify the functions in the static library, you need to re-generate the static library and re-include it. This will be troublesome during the development stage. You can use xcode's cross-project reference (cross-project reference) method.

First, the xcode project of the static library is included in our current project (Note: Do not select the copy items to destination group's folder option ).

Then, it is included in the. A static library like step 2 (also note: do not select the copy items to destination group's folder option ).

In this way, you can directly open the static library project from our current project and modify it directly (Note: You must select clean before compiling after modification, clear the original static library, and generate again ).

Appendix: Reference

In-depth understanding of the iPhone static Library:

Http://blog.csdn.net/dongfengsun/archive/2009/11/20/4840224.aspx

The best way to use static libraries for iPhone projects:

Http://www.iphone-geek.cn/programming /iphoneproject uses the static library Method

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.