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:(NSString *)predicateFormat, ...
{
    va_list args;
    RLM_VARARG(predicateFormat, args);
    return [self indexOfObjectWhere:predicateFormat args:args];
}

- (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat args:(va_list)args
{
    @throw [NSException exceptionWithName:@"RLMNotImplementedException"
                                   reason:@"Method not implemented" userInfo:nil];
}

- (NSUInteger)indexOfObjectWithPredicate:(NSPredicate *)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
{
    const NSUInteger maxObjects = 100;
    NSMutableString *mString = [NSMutableString stringWithString:@"RLMArray (\n"];
    unsigned long index = 0, skipped = 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];
        if (index >= maxObjects) {
            skipped = self.count - maxObjects;
            break;
        }
    }
    
    // Remove last comma and newline characters

Review comment (performance):
This is fine for now and it works for all  RLMArray variants. We can always add optimized implementations for each type - will create a ticket for this. 

> On Jul 30, 2014, at 11:42 AM, astigsen notifications@github.com wrote:
> 
> In Realm/RLMArray.mm:
> 
> >  }
> > - (NSUInteger)indexOfObjectWithPredicate:(NSPredicate *)predicate
> >   {
> >   -    @throw [NSException exceptionWithName:@"RLMNotImplementedException"
> >   -                                   reason:@"Method not implemented" userInfo:nil];
> >   -    RLMArray *objects = [self objectsWithPredicate:predicate];
> >   -    if ([objects count] == 0) {
> >   -        return NSNotFound;
> >   -    }
> >     We are doing far too much work here. There is no need to create an RLMArray (which is a relatively expensive operation). You can use the Query::find() method to get the index directly (without creating any objects or views). It will return tightdb::not_found if there is no match.
> 
> —
> Reply to this email directly or view it on GitHub.


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:(NSString *)predicateFormat, ...
{
    va_list args;
    RLM_VARARG(predicateFormat, args);
    return [self indexOfObjectWhere:predicateFormat args:args];
}

- (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat args:(va_list)args
{
    return [self indexOfObjectWithPredicate:[NSPredicate predicateWithFormat:predicateFormat
                                                                   arguments:args]];
}

- (NSUInteger)indexOfObjectWithPredicate:(NSPredicate *)predicate
{
    RLMArray *objects = [self objectsWithPredicate:predicate];
    if ([objects count] == 0) {
        return NSNotFound;
    }
    return [self indexOfObject:[objects firstObject]];
}
#pragma GCC diagnostic pop

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


#pragma mark - Superclass Overrides

- (NSString *)description
{
    const NSUInteger maxObjects = 100;
    NSMutableString *mString = [NSMutableString stringWithString:@"RLMArray (\n"];
    unsigned long index = 0, skipped = 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];
        if (index >= maxObjects) {
            skipped = self.count - maxObjects;
            break;
        }