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):
This is the first way I had tried. This doesn't work.

![image](https://cloud.githubusercontent.com/assets/474794/3291834/714a744e-f588-11e3-8635-1f340218df81.png)


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;