Establishment and use of IOS static class library

Source: Internet
Author: User

Establishment and use of IOS static class library

Create xcode Workspace

Open xcode, select File-> New-> workspace, name the workspace test. xcworkspace, and select the appropriate directory.

Create a static library project

Select File-> New-> Project, select cocoa touch static library as the project template, and name the project name mylib. xcodeproj. Note that use automatic reference counting is selected.

Xcode will automatically generate the mylib. h and mylib. M files in the project, click the mylib. h file, and add the following two method definitions:

?
12 -
(NSInteger) add:(NSInteger)a and:(NSInteger)b;
+
(NSString*) connect:(NSString*)str1 and:(NSString*)str2;

Open the mylib. M file and add the implementation of the two files just defined:

- (NSInteger) add:(NSInteger)a and:(NSInteger)b {   return a + b;}+ (NSString*) connect:(NSString *)str1 and:(NSString *)str2 {   return [NSString stringWithFormat:@"%@ %@", str1, str2];}

Now, the final file looks like this:

?
12345678910111213141516171819202122232425262728
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.