https://github.com/sschmid/floc-reflection
Reflection for Objective-C.
https://github.com/sschmid/floc-reflection
Last synced: over 1 year ago
JSON representation
Reflection for Objective-C.
- Host: GitHub
- URL: https://github.com/sschmid/floc-reflection
- Owner: sschmid
- License: mit
- Created: 2013-07-05T16:30:16.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2013-07-09T17:16:30.000Z (about 13 years ago)
- Last Synced: 2024-03-15T12:08:35.701Z (over 2 years ago)
- Language: Objective-C
- Size: 246 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Floc Reflection

[](https://travis-ci.org/sschmid/Floc-Reflection)
## Description
Floc Reflection is a set of class methods to easily inspect objects in Objective-C.
## How to use Floc Reflection
#### Inspect an object
```objective-c
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
```objective-c
NSArray *propertyNames = [FLReflection getAllPropertyNamesOfClass:[Car class]];
NSLog(@"propertyNames = %@", propertyNames); // [@"wheel", @"engine"]
```
#### Get the property type of a class
```objective-c
// returns class 'Wheel'
id wheelType = [FLReflection getTypeForProperty:@"wheel"
ofClass:[Car class]];
// returns protocol
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.
[CocoaPods]: http://cocoapods.org