Comments (5)
➤ PM Bot commented:
Jira ticket: RCOCOA-2295
from realm-swift.
Question: To me, an empty section would just be a section header with no rows following. Is that the case here?
It would be helpful to see a minimal example of the issue so we can see how the sections are being defined and what an 'empty' section would look like.
from realm-swift.
Question: To me, an empty section would just be a section header with no rows following. Is that the case here?
It would be helpful to see a minimal example of the issue so we can see how the sections are being defined and what an 'empty' section would look like.
It could be. For example, if you had a hierarchy of data (like a file system) and had a directory without childrens, then you would have an empty section.
The case in our app is that we want to have sections based on that "status" of an object: "Paused" and "Finished". Here are screenshots that depict it.
from realm-swift.
Allow me to think through this at kind of a high level here.
It's up to you, the developer to determine how 'sections' are derived. For example, if you have a contact list and want sections by the first letter representing each contact it would be something like this in Swift
@ObservedSectionedResults(Contact.self, sectionKeyPath: \.firstLetter)
or suppose you want to have sections representing States in the US that are stored in your database.
@ObservedSectionedResults(USState.self, sectionKeyPath: \.stateName)
In other words, the section headers are derived from the data itself. If there is no contact starting with "Z" then there's no "Z" section. If there's no state "Florida", there would be no section "Florida".
I would think the simple solution is to pre-populate your database with objects that you know will represent the headers, but with nil or empty properties and a property to indicate if it's a section header or not.
class Contact: Object {
@Persisted var firstLetter = ""
@Persisted var contactName = ""
@Persisted var isHeader = false
}
let contactA = Contact()
contactA.firstLetter = "A"
contactA.isHeader = true
let contactB = Contact()
contatB.firstLetter = "B"
contactB.isHeader = true
then when the app starts, ensure all contacts that are headers are written which forces every section to have a header whether or not there's any actual rows within that header.
From there - just ensure queries exclude headers from their results.
Just a thought!
from realm-swift.
That might work. It feels forced but might be a viable workaround. I'll play with it and see how it works.
from realm-swift.
Related Issues (20)
- Crash when using RealmSwift with multiple modules (ver 10.49.1) HOT 1
- Issue with Nested Bundles and Disallowed Files When Archiving with Realm-Swift HOT 1
- Doesn't work with cocoapods HOT 3
- Add Sync tests for Collections in mixed HOT 1
- Code sign XCFramework HOT 1
- Realm 10.51.0 not available in SPM HOT 3
- Add append function to `@ObservedSectionedResults` HOT 1
- Crashing 100% when using @available(..., *) for a dynamic library in ObjC HOT 3
- Consider implementing a SwiftData Custom Store (new in iOS18) for Realm HOT 6
- Xcode 16: Write Blocks Risk Data Races Warnings HOT 11
- Update all uses of _unsafeInheritExecutor to use #isolation instead HOT 1
- Code sign our published xcframeworks HOT 1
- Update Binding for iOS 18's API changes HOT 1
- Switch to building RealmSwift in Swift 6 mode HOT 1
- Investigate explicitly built modules for RealmSwift HOT 1
- Add support for logging categories HOT 1
- After upgrading to 10.52.0 our app crashes on launch when we attempt to observe a collection HOT 2
- App crash for iOS 12 using 'RealmSwift', '~> 3.20.0' HOT 5
- Delete Realm if file is an unsupported version HOT 1
- Is it possible to fully deallocate the Memory used by Realm HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from realm-swift.