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 |