YapDatabase icon indicating copy to clipboard operation
YapDatabase copied to clipboard

Setting mapping's range option for inserted groups

Open ERussel opened this issue 11 years ago • 4 comments

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.

ERussel avatar Jun 14 '14 19:06 ERussel

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...?

nevsi avatar Jul 10 '15 16:07 nevsi

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 avatar Jul 10 '15 18:07 robbiehanson

@robbiehanson thank you for your reply! Would you mind pointing to an example with mappings.isDynamicSection where this problem was solved. Thanks

nevsi avatar Jul 10 '15 21:07 nevsi

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.

robbiehanson avatar Aug 10 '15 21:08 robbiehanson