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

Remove default implementation Reflectable for NSObject #14

Open
kolbasek opened this issue May 24, 2019 · 3 comments
Open

Remove default implementation Reflectable for NSObject #14

kolbasek opened this issue May 24, 2019 · 3 comments

Comments

@kolbasek
Copy link

Hi, I use your nice PrediKit to filter realm Results, works pretty good, but needs particular implementation of the properties() method
My variant:

extension Object: Reflectable {
    public static func properties() -> [Selector] {
        guard let schema = self.sharedSchema() else { return [] }
        let properties = schema.properties.map {
            Selector($0.name)
        }

        let computedProperties = schema.computedProperties.map {
            Selector($0.name)
        }

        return properties+computedProperties
    }
}

Problem is the following: Object inherited from NSObject, so I can't override your implementation in the NSObject extension

@hectormatos2011
Copy link
Contributor

Thanks for this! I'll look into it

@hectormatos2011
Copy link
Contributor

Also feel free to make a PR if you want! For some context, I made the protocol force NSObject conformance because there was no reflection into Swift properties on a class at the time as well as the fact that you aren't allowed to extend AnyObject or Any for Swift objects. Given that we now have keyPaths and Mirror, this may no longer be the case. For now though, I may just make reflectable a base protocol and create a separate objective c protocol that extends it so that way the default implementation for objective c objects don't break.

Would that still work for your project? If so, it's a fairly easy fix and should make for an easy pr. I can do it too when I'm near a computer so whichever works best for you!

@kolbasek
Copy link
Author

Sounds cool, I think this will work

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

2 participants