YapDatabaseViewGrouping
@interface YapDatabaseViewGrouping : NSObject
The grouping block handles both filtering and grouping.
When you add or update rows in the database the grouping block is invoked. Your grouping block can inspect the row and determine if it should be a part of the view. If not, your grouping block simply returns ‘nil’ and the object is excluded from the view (removing it if needed). Otherwise your grouping block returns a group, which can be any string you want. Once the view knows what group the row belongs to, it will then determine the position of the row within the group (using the sorting block).
It is recommended you choose a block type that takes the minimum number of required parameters. This allows the view to make various optimizations based on the required parameters of the block.
If you’d like to get more advanced, you can specify exactly what should trigger an invocation of the block. For example:
If you use a ‘GroupingWithObjectBlock’, then normally the view will assume that any changes to the ‘object’ in
the database means that the groupingBlock should be re-invoked (to check for changes to the group).
However, your groupingBlock may be more static
than that.
That is, it may simply be based on an immutable property of the object.
And as such, it only needs to be run once (because the group will never change).
So you can use the ‘options’ parameter to specify YapDatabaseBlockInvokeOnInsertOnly.
This will allow the view to properly optimize based on the details of your actual groupingBlock implementation.
-
Undocumented
Declaration
Objective-C
+ (instancetype)withKeyBlock:(YapDatabaseViewGroupingWithKeyBlock)block;
Swift
class func withKeyBlock(_ block: @escaping YapDatabaseViewGroupingWithKeyBlock) -> Self
-
Undocumented
Declaration
Objective-C
+ (instancetype)withObjectBlock:(YapDatabaseViewGroupingWithObjectBlock)block;
Swift
class func withObjectBlock(_ block: @escaping YapDatabaseViewGroupingWithObjectBlock) -> Self
-
Undocumented
Declaration
Objective-C
+ (instancetype)withMetadataBlock:(YapDatabaseViewGroupingWithMetadataBlock)block;
Swift
class func withMetadataBlock(_ block: @escaping YapDatabaseViewGroupingWithMetadataBlock) -> Self
-
Undocumented
Declaration
Objective-C
+ (instancetype)withRowBlock:(YapDatabaseViewGroupingWithRowBlock)block;
Swift
class func withRowBlock(_ block: @escaping YapDatabaseViewGroupingWithRowBlock) -> Self
-
Undocumented
Declaration
Objective-C
+ (instancetype)withOptions:(YapDatabaseBlockInvoke)iops keyBlock:(YapDatabaseViewGroupingWithKeyBlock)block;
Swift
class func withOptions(_ iops: YapDatabaseBlockInvoke, keyBlock block: @escaping YapDatabaseViewGroupingWithKeyBlock) -> Self
-
Undocumented
Declaration
Objective-C
+ (instancetype)withOptions:(YapDatabaseBlockInvoke)iops objectBlock:(YapDatabaseViewGroupingWithObjectBlock)block;
Swift
class func withOptions(_ iops: YapDatabaseBlockInvoke, objectBlock block: @escaping YapDatabaseViewGroupingWithObjectBlock) -> Self
-
Undocumented
Declaration
Objective-C
+ (instancetype)withOptions:(YapDatabaseBlockInvoke)iops metadataBlock:(YapDatabaseViewGroupingWithMetadataBlock)block;
Swift
class func withOptions(_ iops: YapDatabaseBlockInvoke, metadataBlock block: @escaping YapDatabaseViewGroupingWithMetadataBlock) -> Self
-
Undocumented
Declaration
Objective-C
+ (instancetype)withOptions:(YapDatabaseBlockInvoke)iops rowBlock:(YapDatabaseViewGroupingWithRowBlock)block;
Swift
class func withOptions(_ iops: YapDatabaseBlockInvoke, rowBlock block: @escaping YapDatabaseViewGroupingWithRowBlock) -> Self
-
Undocumented
Declaration
Objective-C
@property (nonatomic, copy, readonly) YapDatabaseViewGroupingBlock block
Swift
var block: Any { get }
-
Undocumented
Declaration
Objective-C
@property (nonatomic, assign, readonly) YapDatabaseBlockType blockType
Swift
var blockType: YapDatabaseBlockType { get }
-
Undocumented
Declaration
Objective-C
@property (nonatomic, assign, readonly) YapDatabaseBlockInvoke blockInvokeOptions
Swift
var blockInvokeOptions: YapDatabaseBlockInvoke { get }