IPhone static libraryNotes for beginners are the content to be introduced in this article. Let's take a look at the specific content first. PairIPhoneFor the platform,IPhoneOnly official supportStatic LibraryFor more information, seeIPhoneMediumStatic Library.
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.
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 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, include the XCode project of the static library into our current project. Note: Do not select the Copy items to destination group's folder option ).
Then, like step 2, it is included in the. a static library. 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 directly modify it. Note: You must select "clean" before compilation after modification, clear the original static library, and generate again ).
Appendix: Reference
In-depth understandingIPhone 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
Summary:IPhone static libraryI hope this article will help you. For more information, see edit recommendations.