How to create a func() to build OrderBy clauses #385

Open
opened 2025-12-29 18:26:23 +01:00 by adam · 1 comment
Owner

Originally created by @appfabtech on GitHub (Apr 13, 2022).

Hello, and thanks for the great library

I would like to create a function to avoid duplicate code in sort selection (having a table view with 4 different sort asc/desc
like
func buildSort(section: Section, sort: Sort, sortAscending: Bool) -> OrderBy

But I have issues on how to define in function declaration the -> OrderBy return parameter

Any help?

Thanks

Originally created by @appfabtech on GitHub (Apr 13, 2022). Hello, and thanks for the great library I would like to create a function to avoid duplicate code in sort selection (having a table view with 4 different sort asc/desc like func buildSort(section: Section, sort: Sort, sortAscending: Bool) -> OrderBy But I have issues on how to define in function declaration the -> OrderBy return parameter Any help? Thanks
adam added the question label 2025-12-29 18:26:23 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Sep 29, 2022):

OrderBy is a generic type, so you'll have to parameterize the object type:

func buildSort<T>(section: Section, sort: Sort, sortAscending: Bool) -> OrderBy<T>

(assuming Section and Sort there are your app's internal types)

@JohnEstropia commented on GitHub (Sep 29, 2022): `OrderBy` is a generic type, so you'll have to parameterize the object type: ```swift func buildSort<T>(section: Section, sort: Sort, sortAscending: Bool) -> OrderBy<T> ``` (assuming `Section` and `Sort` there are your app's internal types)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore-JohnEstropia#385