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

Code before:
}

-(NSNumber *)averageOfProperty:(NSString *)property {
    @throw [NSException exceptionWithName:@"RLMException"
                                   reason:@"This method can only be called in RLMArray instances retrieved from an RLMRealm" userInfo:nil];
}

- (NSUInteger)indexOfObjectWhere:(id)predicate, ... {
    @throw [NSException exceptionWithName:@"RLMNotImplementedException"
                                   reason:@"Method not implemented" userInfo:nil];
}
#pragma GCC diagnostic pop

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


#pragma mark - Superclass Overrides

- (NSString *)description
{
    NSMutableString *mString = [NSMutableString stringWithString:@"RLMArray (\n"];
    for (NSUInteger index = 0; index < self.count && index < 1000; index++) {
        // Indent child objects
        NSString *objDescription = [[self[index] description] stringByReplacingOccurrencesOfString:@"\n"
                                                                                        withString:@"\n\t"];
        [mString appendFormat:@"\t[%lu] %@,\n", (unsigned long)index, objDescription];
    }

    // Only display the first 1000 objects
    NSUInteger skippedObjects = self.count > 1000 ? self.count - 1000 : 0;
    
    // 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


Review comment (bug):
I switched this back to test the fast enumeration which was crashing. There was no test case to make sure it only prints out 1000 objects.  Will fix in a new pr. 1000 seems beyond useful though - perhaps 100 would be better?


Code after:
}

-(NSNumber *)averageOfProperty:(NSString *)property {
    @throw [NSException exceptionWithName:@"RLMException"
                                   reason:@"This method can only be called in RLMArray instances retrieved from an RLMRealm" userInfo:nil];
}

- (NSUInteger)indexOfObjectWhere:(id)predicate, ... {
    @throw [NSException exceptionWithName:@"RLMNotImplementedException"
                                   reason:@"Method not implemented" userInfo:nil];
}
#pragma GCC diagnostic pop

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


#pragma mark - Superclass Overrides

- (NSString *)description
{
    NSMutableString *mString = [NSMutableString stringWithString:@"RLMArray (\n"];
    unsigned long index = 0;
    for (NSObject *obj in self) {
        // Indent child objects
        NSString *objDescription = [obj.description stringByReplacingOccurrencesOfString:@"\n" withString:@"\n\t"];
        [mString appendFormat:@"\t[%lu] %@,\n", index++, objDescription];
    }
    
    // Only display the first 1000 objects
    NSUInteger skippedObjects = self.count > 1000 ? self.count - 1000 : 0;
    
    // 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