我有一个 Objective-C 静态库(iOS SDK 6):
实施文件 ( .m )
#import "MyClass.h"
@implementation MyClass
static id _instance;
static NSString *version;
- (id)init {
if(_instance == nil) {
_instance = [super init];
version = @"1.0";
}
return _instance;
}
- (NSString *)getVersion {
return version;
}
+ (MyClass *)sharedInstance {
return _instance;
}
@end
当我访问其他 iPhone App 项目中的类(导入库)时,我无法获取版本字符串。
#import "ViewController.h"
#import <MyClass/MyClass.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
MyClass *cls = [MyClass sharedInstance];
NSLog(@"Loaded. Version: %@", [cls getVersion]);
}
@end
我错过了什么?没有报错,但是版本是(null)