polqf / RealmResultsController

A NSFetchedResultsController implementation for Realm written in Swift
MIT License
188 stars 25 forks source link

Iterate properties with scheme properties #64

Closed ngs closed 8 years ago

ngs commented 8 years ago

Updated getMirror to iterate properties with scheme properties

polqf commented 8 years ago

Hi @ngs , First of all, thanks for the PR.

The reason why we are not mirroring the properties that are objects at the moment is because that could lead in an endless loop.

Imagine something like this:

Task <---------> User

if you mirror the task, it is going to mirror the user, and that mirroring is going to mirror the task...

ngs commented 8 years ago

@poolqf Thank you for your feedback.

I created this PR because getMirror caused crashing by accessing valueForKey with key contained in ignoredProperties().

How do you think about skipping values by checking ignoredProperties() ?

let ignoredProperties = (self.dynamicType as Object.Type).ignoredProperties()

// and inside loop
guard let key = c.1.0       
  where !key.hasSuffix(".storage") && !ignoredProperties.contains(key) else { continue }
polqf commented 8 years ago

Without a deeper look, I find it is correct @ngs , but only for users that don't use this ignored properties

Maybe this should something that the user should be able to enable or not. There could be the case where the user wants to use this ignored properties...

ngs commented 8 years ago

Okay, I'll implement base class to override getMirror, thanks :bow: