# Import
@ Implementation NSObject (PropertyListing)
/* Obtain all attributes of an object */
-(NSDictionary *) properties_aps
{
NSMutableDictionary * props = [NSMutableDictionary dictionary];
Unsigned int outCount, I;
Objc_property_t * properties = class_copyPropertyList ([self class], & outCount );
For (I = 0; I
{
Objc_property_t property = properties [I];
Const char * char_f = property_getName (property );
NSString * propertyName = [NSString stringwithuf8string: char_f];
Id propertyValue = [self valueForKey :( NSString *) propertyName];
If (propertyValue) [props setObject: propertyValue forKey: propertyName];
}
Free (properties );
Return props;
}
/* Get all methods of the object */
-(Void) printMothList
{
Unsigned int mothCout_f = 0;
Method * mothList_f = class_copyMethodList ([self class], & mothCout_f );
For (int I = 0; I
{
Method temp_f = mothList_f [I];
IMP imp_f = method_getImplementation (temp_f );
SEL name_f = method_getName (temp_f );
Const char * name_s = sel_getName (method_getName (temp_f ));
Int arguments = method_getNumberOfArguments (temp_f );
Const char * encoding = method_getTypeEncoding (temp_f );
NSLog (@ "method name: % @, number of parameters: % d, encoding method: % @", [NSString stringwithuf8string: name_s],
Arguments,
[NSString stringwithuf8string: encoding]);
}
Free (mothList_f );
}
@ End