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