https://github.com/sschmid/gummi-reflection
Reflection for Objective-C
https://github.com/sschmid/gummi-reflection
Last synced: over 1 year ago
JSON representation
Reflection for Objective-C
- Host: GitHub
- URL: https://github.com/sschmid/gummi-reflection
- Owner: sschmid
- License: mit
- Created: 2013-01-10T16:44:05.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2013-04-04T15:57:46.000Z (over 13 years ago)
- Last Synced: 2025-02-13T20:44:14.166Z (over 1 year ago)
- Language: Objective-C
- Homepage: http://sschmid.github.com/Gummi-Reflection/
- Size: 334 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Gummi Reflection

## Description
Gummi Reflection is a set of class methods to easily inspect objects in Objective-C. It's a small subproject mainly used by [Gummi Injection] and [Gummi Commander].
## How to use Gummi Reflection
#### Inspect an object
```objective-c
Car *car = [[Car alloc] init];
BOOL isClass = [GRReflection isClass:car];
BOOL isProtocol = [GRReflection isProtocol:car];
BOOL isBlock = [GRReflection isBlock:car];
BOOL isInstance = [GRReflection 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 = [GRReflection getAllPropertyNamesOfClass:[Car class]];
NSLog(@"propertyNames = %@", propertyNames); // [@"wheel", @"engine"]
```
#### Get the property type of a class
```objective-c
// returns class 'Wheel'
id wheelType = [GRReflection getTypeForProperty:@"wheel"
ofClass:[Car class]];
// returns protocol
id engineType = [GRReflection getTypeForProperty:@"engine"
ofClass:[Car class]];
```
## Install Gummi Reflection
You find the source files you need in Gummi-Reflection/Classes.
## CocoaPods
Install [CocoaPods] and add the Gummi Reflection reference to your Podfile
```
platform :ios, '5.0'
pod 'Gummi-Reflection'
end
```
#### Add this remote
```
$ pod repo add sschmid-cocoapods-specs https://github.com/sschmid/cocoapods-specs
```
#### Install Gummi Reflection
```
$ cd path/to/project
$ pod install
```
Open the created Xcode Workspace file.
## Projects that use Gummi Reflection
* [Gummi Injection] - A lightweight dependency injection framework for Objective-C
* [Gummi Commander] - Event Command Mapping System for Objective-C
[CocoaPods]: http://cocoapods.org
[Gummi Injection]: https://github.com/sschmid/Gummi-Injection
[Gummi Commander]: https://github.com/sschmid/Gummi-Commander