Latest 0.1.0
Homepage https://github.com/leoschweizer/Heliograph
License MIT
Platforms ios 6.0, osx 10.7, requires ARC
Authors

Build Status
Coverage Status
Carthage compatible
CocoaPods Version

Heliograph is an object-oriented, mirror-based, extensible wrapper around Objective-C’s runtime reflection capabilities.

Building

The easiest way to include Heliograph in your project is through CocoaPods:

pod 'Heliograph'

Heliograph also supports Carthage:

github "leoschweizer/Heliograph"

Usage

The central entry point into the mirrored reflection world is the reflect function:

#import <Heliograph/Heliograph.h>

HGClassMirror *classMirror = reflect([NSString class]);
HGProtocolMirror *protocolMirror = reflect(@protocol(NSSecureCoding));
HGObjectMirror *objectMirror = reflect(@"Heliograph");

Fun fact: You can use Heliograph to reason about the functionality of Heliograph!

#import <Heliograph/Heliograph.h>

HGClassMirror *class = reflect([HGClassMirror class]);
for (HGMethodMirror *each in [class methods]) {
    NSLog(@"- %@", NSStringFromSelector([each selector]));
}
for (HGMethodMirror *each in [[class classMirror] methods]) {
    NSLog(@"+ %@", NSStringFromSelector([each selector]));
}

// =>
// - adoptedProtocols
// - adoptProtocol:
// - instanceVariableNamed:
// - methodNamed:
// - subclasses
// - addInstanceVariableNamed:withEncoding:
// - addMethodNamed:withImplementation:andEncoding:
// ...
// + allClasses

HGMethodMirror *method = [class methodNamed:@selector(addMethodNamed:withImplementation:andEncoding:)];
for (id<HGTypeMirror> each in [method argumentTypes]) {
    NSLog(@"%@", [each typeDescription]);
}

// =>
// SEL
// ^
// unknown type

Example Snippets

Note: Heliograph works hand in glove with OpinionatedC, that’s why many
of the snippets listed here use both Heliograph and OpinionatedC!

Contributing

If you have any questions, remarks, ideas or suggestions for improvement, don’t hesitate to open an issue. If you are about to create a pull request, there are only a few things to consider:

  • open an issue first if you are not sure if your idea will be appreciated
  • indent with tabs, not spaces
  • write unit tests, aim for 100% coverage

Contributors

License

The MIT License (MIT)

Copyright (c) 2016 Leo Schweizer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Latest podspec

{
    "name": "Heliograph",
    "version": "0.1.0",
    "summary": "Mirror-based reflection for Objective-C",
    "description": "Heliograph is an object-oriented, mirror-based, extensible wrapper around nObjective-C's runtime reflection capabilities.",
    "homepage": "https://github.com/leoschweizer/Heliograph",
    "social_media_url": "https://twitter.com/leoschweizer",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Leo Schweizer": "[email protected]"
    },
    "source": {
        "git": "https://github.com/leoschweizer/Heliograph.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "6.0",
        "osx": "10.7"
    },
    "requires_arc": true,
    "default_subspecs": "Core",
    "subspecs": [
        {
            "name": "Core",
            "source_files": [
                "Lib/*.h",
                "Lib/Core/**/*.{h,m}",
                "Lib/Visitors/**/*.{h,m}"
            ]
        }
    ]
}

Pin It on Pinterest

Share This