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):
Yes, I think that 100 will be enough. You will usually only use it to get
an idea of what is in there.

On Sat, Jun 7, 2014 at 12:08 AM, Ari Lazier notifications@github.com
wrote:

> In Realm/RLMArray.mm:
> 
> > @@ -191,13 +191,13 @@ - (NSString *)JSONString {
> > - (NSString *)description
> >   {
> >      NSMutableString *mString = [NSMutableString stringWithString:@"RLMArray (\n"];
> >   -    for (NSUInteger index = 0; index < self.count && index < 1000; index++) {
> >   -    unsigned long index = 0;
> >   -    for (NSObject *obj in self) {
> 
> 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?
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/realm/realm-objc/pull/388/files#r13513075.


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