そのため、xcode 4.2 から 4.3 に切り替えたところ、シングルトンを作成/使用する古い方法が機能しなくなりました。だから私はシングルトンを設定する方法について調査を行い、このコードをここに持っています。
GlobalLogin.h
@interface GlobalLogin : UIViewController
+(GlobalLogin *)sharedInstance;
@end
GlobalLogin.m
@implementation GlobalLogin
#pragma mark -
#pragma mark Singleton Methods
+ (GlobalLogin*)sharedInstance {
static GlobalLogin * sharedInstance;
if(!sharedInstance) {
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
sharedInstance = [[super allocWithZone:nil] init];
});
}
return sharedInstance;
}
+ (id)allocWithZone:(NSZone *)zone {
return [self sharedInstance];
}
- (id)copyWithZone:(NSZone *)zone {
return self;
}
#if (!__has_feature(objc_arc))
- (id)retain {
return self;
}
- (unsigned)retainCount {
return UINT_MAX; //denotes an object that cannot be released
}
- (void)release {
//do nothing
}
- (id)autorelease {
return self;
}
#endif
#pragma mark -
#pragma mark Custom Methods
だから私は大丈夫ですが、私の問題は、それを使用する必要があるさまざまなView Controllerでその情報にアクセスする方法がどこにも見つからないことです。誰かが私を正しい方向に向けることができれば、それは大歓迎です。