Heliograph 0.1.0

Heliograph 0.1.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Jan 2016

Maintained by Leo Schweizer.



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'

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.