Coder Social home page Coder Social logo

floc-reflection's Introduction

Floc Reflection

Floc Reflection Logo Build Status

Description

Floc Reflection is a set of class methods to easily inspect objects in Objective-C.

How to use Floc Reflection

Inspect an object

Car *car = [[Car alloc] init];

BOOL isClass = [FLReflection isClass:car];
BOOL isProtocol = [FLReflection isProtocol:car];
BOOL isBlock = [FLReflection isBlock:car];
BOOL isInstance = [FLReflection isInstance:car];

NSLog(@"isClass = %d", isClass);        // NO
NSLog(@"isProtocol = %d", isProtocol);  // NO
NSLog(@"isBlock = %d", isBlock);        // NO
NSLog(@"isInstance = %d", isInstance);  // YES

Get all property names of a class

NSArray *propertyNames = [FLReflection getAllPropertyNamesOfClass:[Car class]];
NSLog(@"propertyNames = %@", propertyNames);  // [@"wheel", @"engine"]

Get the property type of a class

// returns class 'Wheel'
id wheelType = [FLReflection getTypeForProperty:@"wheel"
                                        ofClass:[Car class]];

// returns protocol <Engine>
id engineType = [FLReflection getTypeForProperty:@"engine"
                                         ofClass:[Car class]];

Install Floc Reflection

You find the source files you need in Floc-Reflection/Classes.

CocoaPods

Install CocoaPods and add the Floc Reflection reference to your Podfile

platform :ios, '5.0'
  pod 'Floc-Reflection'
end

Install Floc Reflection

$ cd path/to/project
$ pod install

Open the created Xcode Workspace file.

floc-reflection's People

Contributors

sschmid avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

elliotchance

floc-reflection's Issues

Don't use exceptions

Please do not use exceptions for something that's not absolutely fatal as this is against general ObjC principles, instead return nil or return the error through and options NSError parameter.

It is common for people to have "Break on All Exceptions" activated in Xcode as an early eject for critical problems that will happen later that are difficult to debug. In this case it's something that can and should be handled gracefully by testing the return value.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.