Repository: realm/realm-swift
File: tools/RealmBrowser/RealmBrowser/Classes/RLMApplicationDelegate.m (Objective-C)

Code before:
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

#import "RLMApplicationDelegate.h"

#import <Realm/Realm.h>
#import "RLMTestDataGenerator.h"

#import "TestClasses.h"

const NSUInteger kTestDatabaseSizeMultiplicatorFactor = 2000;
const NSUInteger kTopTipDelay = 250;
const NSUInteger kMaxFilesPerCategory = 7;
const CGFloat kMenuImageSize = 16;

NSString *const kRealmFileExension = @"realm";


@interface RLMApplicationDelegate ()

@property (nonatomic, weak) IBOutlet NSMenu *fileMenu;
@property (nonatomic, weak) IBOutlet NSMenuItem *openMenuItem;
@property (weak) IBOutlet NSMenu *openAnyRealmMenu;

@property (nonatomic) NSDateFormatter *dateFormatter;

@property (nonatomic) BOOL didLoadFile;

@property (nonatomic) NSMetadataQuery *query;
@property (nonatomic) NSArray *groupedFileItems;

@end

@implementation RLMApplicationDelegate

-(void)applicationDidFinishLaunching:(NSNotification *)notification
{
    [[NSUserDefaults standardUserDefaults] setObject:@(kTopTipDelay) forKey:@"NSInitialToolTipDelay"];
    
    if (!self.didLoadFile) {
        NSInteger openFileIndex = [self.fileMenu indexOfItem:self.openMenuItem];
        [self.fileMenu performActionForItemAtIndex:openFileIndex];
        
        self.query = [[NSMetadataQuery alloc] init];
        [self.query setSortDescriptors:@[[[NSSortDescriptor alloc] initWithKey:(id)kMDItemContentModificationDate ascending:NO]]];
        
        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(kMDItemFSName like[c] %@)", @"*.realm"];
        [self.query setPredicate:predicate];
        

Review comment (suggestion):
Not in itself, but I have added and removed properties all over the place in my other branches, perhaps not in the class, so I could do it here and then do it for the other files later.


Code after:
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

#import "RLMApplicationDelegate.h"

#import <Realm/Realm.h>
#import "RLMTestDataGenerator.h"

#import "TestClasses.h"

const NSUInteger kTopTipDelay = 250;
const NSUInteger kMaxFilesPerCategory = 7;
const CGFloat kMenuImageSize = 16;

NSString *const kRealmFileExension = @"realm";
NSString *const kDeveloperFolder = @"/Developer";
NSString *const kSimulatorFolder = @"/Library/Application Support/iPhone Simulator";
NSString *const kDesktopFolder = @"/Desktop";
NSString *const kDownloadFolder = @"/Download";
NSString *const kDocumentsFolder = @"/Documents";

@interface RLMApplicationDelegate ()

@property (nonatomic, weak) IBOutlet NSMenu *fileMenu;
@property (nonatomic, weak) IBOutlet NSMenuItem *openMenuItem;
@property (nonatomic, weak) IBOutlet NSMenu *openAnyRealmMenu;

@property (nonatomic, strong) NSDateFormatter *dateFormatter;

@property (nonatomic, assign) BOOL didLoadFile;

@property (nonatomic, strong) NSMetadataQuery *realmQuery;
@property (nonatomic, strong) NSMetadataQuery *appQuery;
@property (nonatomic, strong) NSMetadataQuery *projQuery;
@property (nonatomic, strong) NSArray *groupedFileItems;

@end

@implementation RLMApplicationDelegate

-(void)applicationDidFinishLaunching:(NSNotification *)notification
{
    [[NSUserDefaults standardUserDefaults] setObject:@(kTopTipDelay) forKey:@"NSInitialToolTipDelay"];
    
    if (!self.didLoadFile) {
        NSInteger openFileIndex = [self.fileMenu indexOfItem:self.openMenuItem];
        [self.fileMenu performActionForItemAtIndex:openFileIndex];
        
        self.realmQuery = [[NSMetadataQuery alloc] init];