0
我並不常見這個問題。BOOL在Singleton中返回NULL的變量
我剛回到Objective-C,它讓我頭疼。
我單身.H
@interface BFTDataHandler : NSObject
+ (BFTDataHandler *)sharedInstance;
@property BOOL *initialLogin;
@property BOOL *PPAccepted;
@property(nonatomic, retain) NSString *Username;
@property(assign) NSString *EDEmail;
@property(nonatomic, retain) NSString *UID;
@property(assign) NSString *Longitude;
@property(assign) NSString *Latitude;
@end
我辛格爾頓.M
#import "BFTDataHandler.h"
@implementation BFTDataHandler
-(id)init
{
self = [super init];
if (self) {
//initlize data
_Username = nil;
_EDEmail = nil;
_UID = nil;
_Longitude = nil;
_Latitude = nil;
_initialLogin = false;
_PPAccepted = false;
}
return self;
}
+ (BFTDataHandler *)sharedInstance
{
static BFTDataHandler *_sharedInstance = nil;
static dispatch_once_t onceSecurePredicate;
dispatch_once(&onceSecurePredicate,^
{
_sharedInstance = [[self alloc] init];
});
return _sharedInstance;
}
我會嘗試訪問PPAccepted BOOL並不斷返回NULL
NSLog(@"%s", [[BFTDataHandler sharedInstance] PPAccepted]);
return *[[BFTDataHandler sharedInstance]PPAccepted];
我找不出該問題,在此先感謝幫助
非常感謝你....有時它的深夜會讓人難以記起最簡單的事情哈哈 – Keeano