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

Logging properties #12

Open
mmackh opened this issue Mar 21, 2021 · 2 comments
Open

Logging properties #12

mmackh opened this issue Mar 21, 2021 · 2 comments

Comments

@mmackh
Copy link

mmackh commented Mar 21, 2021

thank you for coming up with such a novel way of exploring / calling APIs. When searching for the right API to call, it's sometimes useful to log an object's properties. Is this something you'd consider adding to the framework?

extension NSObject {
    var properties: [String] {
        var count : UInt32 = 0
        let typeOf = type(of: self)
        guard let properties: UnsafeMutablePointer<objc_property_t> = class_copyPropertyList(typeOf, &count) else { return [] }
        var names: [String] = []
        for i in 0..<Int(count) {
            let property : objc_property_t = properties[i]
            guard let name = NSString(utf8String: property_getName(property)) as String? else { continue }
            names.append(name as String)
        }
        free(properties)
        return names
    }
}
@polymerchm
Copy link

you can do Dynamic(xxxx).asObject.properties with your extension.

@mmackh
Copy link
Author

mmackh commented Mar 22, 2021

Yes, I was wondering if this is something that should be added to the framework

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