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

Support transient properties for sectionNameKeyPath #101

Open
michelalbers opened this issue Jun 23, 2016 · 4 comments
Open

Support transient properties for sectionNameKeyPath #101

michelalbers opened this issue Jun 23, 2016 · 4 comments

Comments

@michelalbers
Copy link

michelalbers commented Jun 23, 2016

I think it would be beneficial to have transient property support in the sectionNameKeyPath, e.g.:

class News : Object {
  dynamic var section : String {
    get {
      if self.didRead == true {
          return "Old news"
      } else {
          return " New news"
      }
    }
  }

  ...  
}

While this works ... kinda ... it produces a lot of crashes complaining about a non-stored property. This would solve the issue with using NSDate #58 as sectionNameKeyPath as well.

@bigfish24
Copy link
Contributor

What is the specific crash that is produced?

@michelalbers
Copy link
Author

michelalbers commented Jul 1, 2016

@bigfish24: the error produced: Terminating app due to uncaught exception 'Invalid sort property', reason: 'Cannot sort on property 'section' on object of type 'Post': property not found.'

Full crashlog:

Terminating app due to uncaught exception 'Invalid sort property', reason: 'Cannot sort on property 'section' on object of type 'Post': property not found.'


0   CoreFoundation                      0x0000000106a7ed85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000108eeadeb objc_exception_throw + 48
    2   Realm                               0x0000000105620a47 _ZL15RLMPreconditionbP8NSStringS0_z + 647
    3   Realm                               0x0000000105623b8c _ZN12_GLOBAL__N_127RLMValidatedPropertyForSortEP15RLMObjectSchemaP8NSString + 364
    4   Realm                               0x00000001056235a7 _Z27RLMSortOrderFromDescriptorsP15RLMObjectSchemaP7NSArray + 679
    5   Realm                               0x0000000105728f04 _ZZ44-[RLMResults sortedResultsUsingDescriptors:]ENK4$_12clEv + 180
    6   Realm                               0x00000001057271d6 _ZL15translateErrorsIZ44-[RLMResults sortedResultsUsingDescriptors:]E4$_12EDaOT_P8NSString + 38
    7   Realm                               0x0000000105727158 -[RLMResults sortedResultsUsingDescriptors:] + 72
    8   RBQFetchedResultsController         0x000000010547d00a -[RBQFetchRequest fetchObjects] + 442
    9   RBQFetchedResultsController         0x000000010547014b -[RBQFetchedResultsController createCacheWithRealm:cacheName:forFetchRequest:sectionNameKeyPath:] + 219
    10  RBQFetchedResultsController         0x0000000105469f4d -[RBQFetchedResultsController performFetch] + 445
    11  SwiftFetchedResultsController       0x0000000105e3c677 _TFC29SwiftFetchedResultsController24FetchedResultsController12performFetchfT_Sb + 39

Any help would be greatly appreciated. Thank you for your awesome work anyway :)

@afinlayson
Copy link

I'm also trying to do this. Would like to use a readonly property (transient) to sort and make sectionNameKeyPath

@inPhilly
Copy link

Any thoughts on this? NSFetchedResultsController does this flawlessly, and much of the code I am trying to convert relies on that. It is not really feasible to add a bunch of new fields in order to store sectionNameKeyPath information. This is kind of a big deal... I am interested to know if this is being updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants