您可以使用普通的旧 C 风格:
// ======== yourlib.h =========
#import <Foundation/Foundation.h>
NSString *doStuff();
void print();
//======== yourlib.m =========
#import "yourlib.h"
NSString *doStuff(){
NSString *test = @"hello world";
return test;
}
void print(){
NSLog(@"Hi");
}
或者,您可以使用类别功能附加到现有框架:
// ======= youlib.h ========
#import <Foundation/Foundation.h>
@interface NSString (YourCategory)
+ (NSString *)someStringFromString:(NSString*)string;
- (NSDictionary *)someDictionaryFromString;
@end
// ======= yourlib.m =======
#import "yourlib.h"
@implementation NSString(YourCategory)
+ (NSString *)someStringFromString:(NSString*)string {
...
return aString;
}
- (NSDictionary *)someDictionaryFromString {
...
return aDict;
}
@end