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

Code before:
                                           reason:@"averageOfProperty only supported for int, float and double properties."
                                         userInfo:nil];
    }
}

- (NSString *)JSONString {
    @throw [NSException exceptionWithName:@"RLMNotImplementedException"
                                   reason:@"Not yet implemented" userInfo:nil];
}

- (id)objectAtIndexedSubscript:(NSUInteger)index {
    return [self objectAtIndex:index];
}

- (void)setObject:(id)newValue atIndexedSubscript:(NSUInteger)index {
    [self replaceObjectAtIndex:index withObject:newValue];
}

#pragma mark - Superclass Overrides

- (NSString *)description
{
    NSMutableString *mString = [NSMutableString stringWithString:@"RLMArray (\n"];
    for (RLMObject *object in self) {
        // Indent child objects
        NSString *objDescription = [object.description stringByReplacingOccurrencesOfString:@"\n"
                                                                                 withString:@"\n\t"];
        [mString appendFormat:@"\t%@,\n", objDescription];
    }
    // Remove last comma and newline characters
    [mString deleteCharactersInRange:NSMakeRange(mString.length-2, 2)];
    [mString appendString:@"\n)"];
    
    return [NSString stringWithString:mString];
}

@end


Review comment (bug):
What happens with a billion entries?
We likely should limit the output to some reasonable number (whatever that might be in a debug situation?)


Code after:
                                           reason:@"averageOfProperty only supported for int, float and double properties."
                                         userInfo:nil];
    }
}

- (NSString *)JSONString {
    @throw [NSException exceptionWithName:@"RLMNotImplementedException"
                                   reason:@"Not yet implemented" userInfo:nil];
}

- (id)objectAtIndexedSubscript:(NSUInteger)index {
    return [self objectAtIndex:index];
}

- (void)setObject:(id)newValue atIndexedSubscript:(NSUInteger)index {
    [self replaceObjectAtIndex:index withObject:newValue];
}

#pragma mark - Superclass Overrides

- (NSString *)description
{
    NSMutableString *mString = [NSMutableString stringWithString:@"RLMArray (\n"];
    NSUInteger index = 0;
    NSUInteger skippedObjects = 0;
    for (RLMObject *object in self) {
        // Only display the first 1000 objects
        if (index == 1000) {
            skippedObjects = [self count] - 1000;
            break;
        }
        
        // Indent child objects
        NSString *objDescription = [object.description stringByReplacingOccurrencesOfString:@"\n"
                                                                                 withString:@"\n\t"];
        [mString appendFormat:@"\t[%lu] %@,\n", (unsigned long)index, objDescription];
        index++;
    }
    // Remove last comma and newline characters
    [mString deleteCharactersInRange:NSMakeRange(mString.length-2, 2)];
    if (skippedObjects > 0) {
        [mString appendFormat:@"\n\t... %lu objects skipped.", (unsigned long)skippedObjects];
    }
    [mString appendFormat:@"\n)"];
    return [NSString stringWithString:mString];
}

@end