Conforms to NSFastEnumeration
Declared in RLMCollection.h

Tasks

RLMCollection Properties

Accessing Objects from a Collection

Querying a Collection

Properties

count

Number of objects in the collection.

@property (nonatomic, readonly, assign) NSUInteger count

Declared In

RLMCollection.h

objectClassName

The class name (i.e. type) of the RLMObjects contained in this RLMCollection.

@property (nonatomic, readonly, copy) NSString *objectClassName

Declared In

RLMCollection.h

realm

The Realm in which this collection is persisted. Returns nil for standalone collections.

@property (nonatomic, readonly) RLMRealm *realm

Declared In

RLMCollection.h

Instance Methods

firstObject

Returns the first object in the collection.

- (nullable id)firstObject

Return Value

An RLMObject of the class contained by this RLMCollection.

Discussion

Returns nil if called on an empty RLMCollection.

Declared In

RLMCollection.h

indexOfObject:

Gets the index of an object.

- (NSUInteger)indexOfObject:(RLMObject *)object

Parameters

object

An object (of the same type as returned from the objectClassName selector).

Discussion

Returns NSNotFound if the object is not found in this RLMCollection.

Declared In

RLMCollection.h

indexOfObjectWhere:

Gets the index of the first object matching the predicate.

- (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat, ...

Parameters

predicateFormat

The predicate format string which can accept variable arguments.

Return Value

Index of object or NSNotFound if the object is not found in this RLMCollection.

Declared In

RLMCollection.h

indexOfObjectWithPredicate:

Gets the index of the first object matching the predicate.

- (NSUInteger)indexOfObjectWithPredicate:(NSPredicate *)predicate

Parameters

predicate

The predicate to filter the objects.

Return Value

Index of object or NSNotFound if the object is not found in this RLMCollection.

Declared In

RLMCollection.h

lastObject

Returns the last object in the collection.

- (nullable id)lastObject

Return Value

An RLMObject of the class contained by this RLMCollection.

Discussion

Returns nil if called on an empty RLMCollection.

Declared In

RLMCollection.h

objectAtIndex:

Returns the object at the index specified.

- (id)objectAtIndex:(NSUInteger)index

Parameters

index

The index to look up.

Return Value

An RLMObject of the class contained by this RLMCollection.

Declared In

RLMCollection.h

objectsWhere:

Get objects matching the given predicate in the RLMCollection.

- (RLMResults *)objectsWhere:(NSString *)predicateFormat, ...

Parameters

predicateFormat

The predicate format string which can accept variable arguments.

Return Value

An RLMResults of objects that match the given predicate

Declared In

RLMCollection.h

objectsWithPredicate:

Get objects matching the given predicate in the RLMCollection.

- (RLMResults *)objectsWithPredicate:(NSPredicate *)predicate

Parameters

predicate

The predicate to filter the objects.

Return Value

An RLMResults of objects that match the given predicate

Declared In

RLMCollection.h

setValue:forKey:

Invokes setValue:forKey: on each of the collection’s objects using the specified value and key.

- (void)setValue:(nullable id)value forKey:(NSString *)key

Parameters

value

The object value.

key

The name of the property.

Discussion

Warning: This method can only be called during a write transaction.

Declared In

RLMCollection.h

sortedResultsUsingDescriptors:

Get a sorted RLMResults from an RLMCollection.

- (RLMResults *)sortedResultsUsingDescriptors:(NSArray *)properties

Parameters

properties

An array of RLMSortDescriptors to sort by.

Return Value

An RLMResults sorted by the specified properties.

Declared In

RLMCollection.h

sortedResultsUsingProperty:ascending:

Get a sorted RLMResults from an RLMCollection.

- (RLMResults *)sortedResultsUsingProperty:(NSString *)property ascending:(BOOL)ascending

Parameters

property

The property name to sort by.

ascending

The direction to sort by.

Return Value

An RLMResults sorted by the specified property.

Declared In

RLMCollection.h

valueForKey:

Returns an NSArray containing the results of invoking valueForKey: using key on each of the collection’s objects.

- (nullable id)valueForKey:(NSString *)key

Parameters

key

The name of the property.

Return Value

NSArray containing the results of invoking valueForKey: using key on each of the collection’s objects.

Declared In

RLMCollection.h