Setting mapping's range option for inserted groups
Hello,
I want to display messages in the UITableView grouped by users. And i want to show only first message for particular user. I use YapDatabaseViewMapping with initWithGroupFilterBlock:sortBlock:view init method and i want to set fixed range options for inserted groups. How can i achieve this goal? I can't do this before groups inserts because i don't know user's id beforehand.
I tried to do this in filter block of the initWithGroupFilterBlock:sortBlock:view method. But it seems doesn't work. My app just freezes.
Hi, is Setting mapping's range option for inserted groups possible then? I tried it, no freeze of the UI as described by others, but it does not seem to have any effect...?
It looks like a similar problem was solved for mappings.isDynamicSection. With that particular property, one can configure a default setting for the property that will apply to any group that isn't explicitly configured otherwise. This design should probably be expanded for rangeOptions, cellDrawingDependencies & isReversed.
@robbiehanson thank you for your reply! Would you mind pointing to an example with mappings.isDynamicSection where this problem was solved. Thanks
I meant that the API for isDynamicSection is more flexible than for other options:
- (void)setIsDynamicSection:(BOOL)isDynamic forGroup:(NSString *)group;
- (BOOL)isDynamicSectionForGroup:(NSString *)group;
- (void)setIsDynamicSectionForAllGroups:(BOOL)isDynamic;
- (BOOL)isDynamicSectionForAllGroups;
Vs:
- (void)setRangeOptions:(YapDatabaseViewRangeOptions *)rangeOpts forGroup:(NSString *)group;
- (YapDatabaseViewRangeOptions *)rangeOptionsForGroup:(NSString *)group;
There are 2 ways one can create a mappings instance:
- with a fixed set of groups via
initWithGroups:view: - with a dynamic set of groups via
initWithGroupFilterBlock:sortBlock:view:
Setting group options (such as rangeOptions) for a non-existent group is allowed if (and only if) mappings was created using a dynamic set of groups.
I think, in general, it needs to be easier to set options for groups that don't exist (yet). And it needs to be easier to add/remove groups from mappings.