iOS Development Static Library production

Source: Internet
Author: User

iOS programs are composed of Objective-c languages, but each class in the Objective-c language is divided into. h. m files. Static libraries can encapsulate the classes of these programs into a. A file, and third-party applications only need to get this. a file and the. h file corresponding to the code can use the encapsulated method in the static library. In general, the iOS static library is suitable for the third party to provide the SDK, nonsense said we go straight to the point.

Make a static library

The code is as follows

1 #import<Foundation/Foundation.h>2 3 @interfaceBookmodellib:nsobject4 {5nsstring*_iconurl;6nsstring*_bookname;7nsstring*_publisher;8nsstring*_price;9nsstring*_authername;Tennsstring*_pubdate; Onensstring*_translator; Ansstring*_introurl; - Nsinteger _numratings; - } the@property (Retain, nonatomic) nsstring*IconUrl; -@property (Retain, nonatomic) nsstring*pubdate; -@property (Retain, nonatomic) nsstring*Introurl; -@property (Retain, nonatomic) nsstring*Authername; +@property (Retain, nonatomic) nsstring*translator;; -@property (Retain, nonatomic) nsstring*BookName; +@property (Retain, nonatomic) nsstring*publisher; A@property (Retain, nonatomic) nsstring*Price ; at @property (Assign, nonatomic) Nsinteger numratings; -  --(void) Showinfo; -  -  - @end
1 #import "BookModelLib.h"2 3 @implementationBookmodellib4 5-(void) Showinfo6 {7NSLog (@"_bookname:%@", _bookname);8NSLog (@"_publisher:%@", _publisher);9NSLog (@"_price:%@", _price);Ten } One  A @end

Cmd+b compile, compile, choose two environment to compile

Merging. A Files

Lipo-create LIBBOOKMODELLIB_OS.A libbookmodellib_lib.a-output LIBBOOKMODELLIB.A

Using a static library

Using a static library is simpler, dragging. h header files and. A files into the project

1 #import "ViewController.h"2 #import "BookModelLib.h"3 4 @interfaceViewcontroller ()5 6 @end7 8 @implementationViewcontroller9 Ten- (void) Viewdidload One { A [Super Viewdidload]; -     //additional setup after loading the view, typically from a nib. -      theBookmodellib *bmodel=[[Bookmodellib alloc]init]; -Bmodel.bookname=@"Fewfwefe"; -Bmodel.iconurl=@"HTTP://FJOEWJF"; -Bmodel.publisher=@"Fewfewfewew"; +Bmodel.price=@"few50"; - [Bmodel Showinfo]; +      A } at  -- (void) didreceivememorywarning - { - [Super didreceivememorywarning]; -     //Dispose of any resources the can be recreated. - } in  - @end

Oh, OK, so you can directly use the static library, super simple wood has ....

iOS Development Static Library production

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.