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

Code before:
        
        RLMTypeNode *displayedType = [self displayedType];
        
        RLMClazzProperty *clazzProperty = displayedType.propertyColumns[columnIndex];
        NSString *propertyName = clazzProperty.name;
        RLMObject *selectedInstance = [displayedType instanceAtIndex:rowIndex];
        NSObject *propertyValue = selectedInstance[propertyName];
        
        switch (clazzProperty.type) {
            case RLMPropertyTypeInt:
            case RLMPropertyTypeBool:
            case RLMPropertyTypeFloat:
            case RLMPropertyTypeDouble:
                if ([propertyValue isKindOfClass:[NSNumber class]]) {
                    return propertyValue;
                }
                break;
                
                
            case RLMPropertyTypeString:
                if ([propertyValue isKindOfClass:[NSString class]]) {
                    return propertyValue;
                }
                break;
                
            case RLMPropertyTypeData:
                return @"<Data>";
                
            case RLMPropertyTypeAny:
                return @"<Any>";
                
            case RLMPropertyTypeDate:
                if ([propertyValue isKindOfClass:[NSDate class]]) {
                    return propertyValue;
                }
                break;
                
            case RLMPropertyTypeArray: {
                RLMArray *referredObject = (RLMArray *)propertyValue;
                return [NSString stringWithFormat:@"List of links to %@", referredObject.objectClassName];
            }
                
            case RLMPropertyTypeObject: {
                RLMObject *referredObject = (RLMObject *)propertyValue;
                if (referredObject == nil) {
                    return @"";
                }
                else {
                    return [NSString stringWithFormat:@"Link to %@", referredObject.objectSchema.className];
                }
            }

Review comment (suggestion):
This is equivalent to `propertyValue != nil ? @"TRUE" : @"FALSE"`. `[propertyValue boolValue] ? @"TRUE" : @"FALSE"` is the correct thing here.


Code after:
        RLMTypeNode *displayedType = [self displayedType];
        RLMClazzProperty *clazzProperty = displayedType.propertyColumns[columnIndex];
        
        NSString *propertyName = clazzProperty.name;
        RLMObject *selectedInstance = [displayedType instanceAtIndex:rowIndex];
        
        NSObject *propertyValue = selectedInstance[propertyName];

        return [self.class printablePropertyValue:propertyValue ofType:clazzProperty.type];
    }
    
    return nil;
}

+(id)printablePropertyValue:(id)propertyValue ofType:(RLMPropertyType)propertyType
{
    return [self printablePropertyValue:propertyValue ofType:propertyType linkFormat:NO];
}

+(id)printablePropertyValue:(id)propertyValue ofType:(RLMPropertyType)propertyType linkFormat:(BOOL)linkFormat
{
    switch (propertyType) {
        case RLMPropertyTypeBool:
            if ([propertyValue isKindOfClass:[NSNumber class]]) {
                if (linkFormat) {
                    return (BOOL)propertyValue ? @"TRUE" : @"FALSE";
                }
                return propertyValue;
            }
            break;

        case RLMPropertyTypeInt:
        case RLMPropertyTypeFloat:
        case RLMPropertyTypeDouble:
            if ([propertyValue isKindOfClass:[NSNumber class]]) {
                return propertyValue;
            }
            break;
            
        case RLMPropertyTypeString:
            if ([propertyValue isKindOfClass:[NSString class]]) {
                return propertyValue;
            }
            break;
        
        case RLMPropertyTypeData:
            if (linkFormat) {
                return @"<Data>";
            }
            
            // Will eventually return an image if present