OOCCollection <NSFastEnumeration>
A Collection represents an unsorted set or sorted list of models of the same type.
- (BOOL) isEmpty
Whether the collection has any object in it or not.
- (NSArray*)arrayValue
An array with all the models in the collection.
- (NSUInteger) size
Number of models in the collection.
- (BOOL) contains:(OOCModel*)model
Whether the collection contains a specific object or not.
- (OOCList) sortBy:(NSString)by limit:(NSUInteger)limit offset:(NSUInteger)offset order:(NSString*)order
A list (sorted collection) sorted by by
, with up to limit
elements starting in offset
.
order
allows to specify how to compare the properties. By default a numeric comparison is made. Its format is [ALPHA] [ASC|DESC]
.
- (OOCList) sortBy:(NSString)by order:(NSString*)order
Calls -sortBy:limit:offset:order: using by
and order
, without a limit.
- (OOCList) sortBy:(NSString)by
Calls -sortBy:limit:offset:order: using by
and order
, without a limit, and using a numeric sort.
- (void)each:(void(^)(id obj, NSUInteger pos, NSUInteger size))block
Asynchronously calls block
on the main thread with each element in the collection.
The block
receives the model obj
, the iteration position pos
and the total number of elements size
in the collection. If the collection is empty, block
will be called with no obj
, and a 0 pos
and size
.
Requires the collection to have be fetched using an OhmocAsync : Ohmoc instance.
- (void)arrayValueCallback:(void(^)(NSArray* arr))block
Asynchronously creates an array with all the models in the collection and calls block
on the main thread.
Requires the collection to have be fetched using an OhmocAsync : Ohmoc instance.
Updated less than a minute ago