Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a different KeyPath to group results #41

Closed
beloso opened this issue Oct 13, 2015 · 5 comments
Closed

Using a different KeyPath to group results #41

beloso opened this issue Oct 13, 2015 · 5 comments
Labels

Comments

@beloso
Copy link

beloso commented Oct 13, 2015

From what I understand RBQFRC uses sectionNameKeyPath in the initialiser to group results by that key path.

In my use case, and perhaps it's a (iffy) corner case, I need to group results via another key path that is not the same as the sectionName.

I'm not sure I am explaining myself correctly.

@bigfish24
Copy link
Contributor

Well I think you could achieve this by using the keypath that you want to group by as the sectionNameKeyPath. However, you would then need to manually handle the section name in the table view itself, by returning the appropriate title in tableView:titleForHeaderInSection: through a different means since the FRC's titleForHeaderInSection: will return the values from the other keypath.

@beloso
Copy link
Author

beloso commented Oct 13, 2015

Thank you for your feedback. That is similar to what I am currently doing.

I am not sure this use case is relevant enough to request a feature for this but could you consider it as a future feature? In order have a better performance, using the FRC cache.

@bigfish24
Copy link
Contributor

Well I guess my concern is it would potentially complicate the API. You could quickly run into problems if the grouping key path produced sections that didn't match the values for the section name key path.

Which come to think about it, confuses me on why you can't just group on the section key path anyway?

What does your data model look like? If the two key path produce the same logical sectioning of the data, why not just use the key path that also happens to be the section names?

@beloso
Copy link
Author

beloso commented Oct 14, 2015

I'll try to explain,

I am trying to display a contact list. Sectioned from A-Z.

There is a flag in each contact, that if switched, I need to display that contact in the same contact list but in another section for it's letter.

I think that ultimately I need to represent two contact lists. A-Z (with the flag ON) and A-Z (with the flag OFF).

UI-wise on the A-Z list (with the ON flag) I will not display the section titles, hence I set their sectionName to "", and that groups all A-Z(ON) in the same section, which due to other logic on my side is unwanted.

I'm not sure I am making sense.

@bigfish24
Copy link
Contributor

I think I understand. Why don't you make a computed property (i.e an ignored property from Realms perspective), that returns the section name:

1, if the flag is YES return the first letter to group it the right section
2. If flag is NO return ""

The FRC can use this computed property to then make sections for "" + A...Z. Those with the switch will be in A...Z and those without will be all together in the separate section.

@beloso beloso closed this as completed Nov 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants