Repository: realm/realm-swift
File: Realm/RLMRealm.mm (Objective-C++)

Code before:
@end


@interface RLMRealm ()
@property (nonatomic) NSString *path;
@property (nonatomic, readwrite) RLMSchema *schema;
@end


NSString *const c_defaultRealmFileName = @"default.realm";
static NSString *s_defaultRealmPath = nil;
static NSArray *s_objectDescriptors = nil;

@implementation RLMRealm {
    UniquePtr<SharedGroup> _sharedGroup;
    NSMapTable *_objects;
    NSRunLoop *_runLoop;
    NSTimer *_updateTimer;
    NSMapTable *_notificationHandlers;
    
    tightdb::Group *_readGroup;
    tightdb::Group *_writeGroup;
}

+ (void)initialize {
    // set up global realm cache
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        // initilize realm cache
        clearRealmCache();
        
        // initialize object store
        RLMInitializeObjectStore();
    });
}

- (instancetype)initWithPath:(NSString *)path readOnly:(BOOL)readonly {
    self = [super init];
    if (self) {
        _path = path;
        _runLoop = [NSRunLoop currentRunLoop];
        _objects = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsOpaquePersonality
                                             valueOptions:NSPointerFunctionsWeakMemory
                                                 capacity:128];
        _notificationHandlers = [NSMapTable mapTableWithKeyOptions:NSPointerFunctionsWeakMemory valueOptions:NSPointerFunctionsWeakMemory];
        _readOnly = readonly;
        _updateTimer = [NSTimer scheduledTimerWithTimeInterval:0.1
                                                        target:[RLMWeakTarget createWithRealm:self]
                                                      selector:@selector(checkForUpdate)
                                                      userInfo:nil
                                                       repeats:YES];

Review comment (suggestion):
We can't make a direct call to core from the tests because that would check the core version linked with tests rather than the version linked with Realm.framework.


Code after:
}
@end


@interface RLMRealm ()
@property (nonatomic) NSString *path;
@property (nonatomic, readwrite) RLMSchema *schema;
@end


NSString *const c_defaultRealmFileName = @"default.realm";
static NSString *s_defaultRealmPath = nil;
static NSArray *s_objectDescriptors = nil;

@implementation RLMRealm {
    UniquePtr<SharedGroup> _sharedGroup;
    NSMapTable *_objects;
    NSRunLoop *_runLoop;
    NSTimer *_updateTimer;
    NSMapTable *_notificationHandlers;
    
    tightdb::Group *_readGroup;
    tightdb::Group *_writeGroup;
}

+ (BOOL)isCoreDebug {
    return tightdb::Version::has_feature(tightdb::feature_Debug);
}

+ (void)initialize {
    // set up global realm cache
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        // initilize realm cache
        clearRealmCache();
        
        // initialize object store
        RLMInitializeObjectStore();
    });
}

- (instancetype)initWithPath:(NSString *)path readOnly:(BOOL)readonly {
    self = [super init];
    if (self) {
        _path = path;
        _runLoop = [NSRunLoop currentRunLoop];
        _objects = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsOpaquePersonality
                                             valueOptions:NSPointerFunctionsWeakMemory
                                                 capacity:128];
        _notificationHandlers = [NSMapTable mapTableWithKeyOptions:NSPointerFunctionsWeakMemory valueOptions:NSPointerFunctionsWeakMemory];
        _readOnly = readonly;