Grayson / nusomewhere

A GUI for NuAnywhere.

This URL has Read+Write access

nusomewhere / NSObject+Inspect.m
100644 31 lines (26 sloc) 0.66 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
// NSObject+Inspect.m
// NuSomewhere
//
// Created by Grayson Hansard on 4/24/09.
// Copyright 2009 From Concentrate Software. All rights reserved.
//
 
#import "NSObject+Inspect.h"
#import <objc/runtime.h>
 
@implementation NSObject (Inspect)
 
-(NSArray *)ivars {
unsigned int ivarCount = 0;
Ivar *ivars = class_copyIvarList([self class], &ivarCount);
if (ivars && ivarCount) {
NSMutableArray *array = [NSMutableArray array];
unsigned int idx = 0;
for (idx=0; idx < ivarCount; idx++) {
Ivar ivar = ivars[idx];
[array addObject:[NSString stringWithUTF8String:ivar_getName(ivar)]];
}
free(ivars);
return array;
}
return nil;
}
 
@end