Fix issue with class method and correct test

This commit is contained in:
Gregory John Casamento 2019-07-08 08:54:44 -04:00
parent ac5983cc1f
commit ee72e4b9c1
2 changed files with 7 additions and 3 deletions

View file

@ -43,7 +43,7 @@ extern "C" {
@interface NSUbiquitousKeyValueStore : NSObject @interface NSUbiquitousKeyValueStore : NSObject
// Getting the Shared Instance // Getting the Shared Instance
- (NSUbiquitousKeyValueStore *) defaultStore; + (NSUbiquitousKeyValueStore *) defaultStore;
// Getting Values // Getting Values
// Returns the array associated with the specified key. // Returns the array associated with the specified key.

View file

@ -34,7 +34,7 @@
#import <Foundation/NSData.h> #import <Foundation/NSData.h>
#import <Foundation/NSString.h> #import <Foundation/NSString.h>
#import <Foundation/NSValue.h> #import <Foundation/NSValue.h>
#import <Foundation/NSUserDefaults.h> #import <Foundation/NSUserDefaults.h>
static NSUbiquitousKeyValueStore *_sharedUbiquitousKeyValueStore = nil; static NSUbiquitousKeyValueStore *_sharedUbiquitousKeyValueStore = nil;
@ -47,13 +47,17 @@ static NSUbiquitousKeyValueStore *_sharedUbiquitousKeyValueStore = nil;
return nil; return nil;
} }
- (NSUbiquitousKeyValueStore *) defaultStore + (NSUbiquitousKeyValueStore *) defaultStore
{ {
if(_sharedUbiquitousKeyValueStore == nil) if(_sharedUbiquitousKeyValueStore == nil)
{ {
NSString *storeClassName = [[NSUserDefaults standardUserDefaults] NSString *storeClassName = [[NSUserDefaults standardUserDefaults]
stringForKey: @"GSUbiquitousKeyValueStoreClass"]; stringForKey: @"GSUbiquitousKeyValueStoreClass"];
Class klass = NSClassFromString(storeClassName); Class klass = NSClassFromString(storeClassName);
if(klass == NULL)
{
klass = NSClassFromString(@"GSSimpleUbiquitousKeyValueStore");
}
_sharedUbiquitousKeyValueStore = [[klass alloc] init]; _sharedUbiquitousKeyValueStore = [[klass alloc] init];
if(_sharedUbiquitousKeyValueStore == nil) if(_sharedUbiquitousKeyValueStore == nil)
{ {