-
Notifications
You must be signed in to change notification settings - Fork 22
Debug View
This NSView subclass adds Textfields and other Views to create a visual represatation of your data. Here is a example of a Person object:
@interface Person : NSObject
@property (nonatomic) NSImage *image;
@property (nonatomic) NSString *firstName;
@property (nonatomic) NSString *lastName;
@property (nonatomic) NSDate *birthday;
- (id)debugQuickLookObject;
@end
@implementation Person
- (id)debugQuickLookObject
{
pkDebugView *view = [pkDebugView debugViewWithAllPropertiesOfObject:self includeSuperclasses:YES];
return view;
}
@end
And the output will look like this:
With this methods you can create debugView with a single line of code.
+ (pkDebugView *)debugView;
Will create an empty DebugView and you have to add data manually.
+ (pkDebugView *)debugViewWithAllPropertiesOfObject:(NSObject *)obj includeSuperclasses:(BOOL)include;
Will create a DebugView with all properties of the given object. The includeSuperclasses option will also add all properties from Superclasses. If you only want the properties from your current class set this option to false;
+ (CocoaDebugView *)debugViewWithProperties:(NSArray *)properties ofObject:(NSObject *)obj;
Will create a debugView with only the allowed properties. Please be careful and make no typing erros in this array of strings because otherwise the generated output may not be valid.
+ (CocoaDebugView *)debugViewWithExcludingProperties:(NSArray *)properties ofObject:(NSObject *)obj;
Will create a DebugView with all properties of the given object except the properties mentioned. This could be useful to limit the generated data.
With this methods you can customize existing DebugViews.
When you create the DebugView on your own use this method to add a title
-(void)setTitle:(NSString *)title
You can either add some properties by specifing the properties in an NSString or simply add all
- (void)addAllPropertiesFromObject:(NSObject *)obj includeSuperclasses:(BOOL)include;
- (void)addProperties:(NSArray *)array fromObject:(NSObject *)obj;
Alternativly you can create you debugView on your own by using this methods.
- (void)addLineWithDescription:(NSString *)desc string:(NSString *)value;
- (void)addLineWithDescription:(NSString *)desc image:(NSImage *)image;
- (void)addLineWithDescription:(NSString *)desc date:(NSDate *)date;
- (void)addLineWithDescription:(NSString *)desc view:(NSView *)view;
- (void)addLineWithDescription:(NSString *)desc color:(NSColor *)color;
- (void)addLineWithDescription:(NSString *)desc error:(NSError *)error;
- (void)addLineWithDescription:(NSString *)desc data:(NSData *)data;
- (void)addLineWithDescription:(NSString *)desc integer:(NSInteger)integer;
- (void)addLineWithDescription:(NSString *)desc unsignedInteger:(NSUInteger)uinteger;
- (void)addLineWithDescription:(NSString *)desc longnumber:(long long)number;
- (void)addLineWithDescription:(NSString *)desc unsignedLongnumber:(unsigned long long)number;
- (void)addLineWithDescription:(NSString *)desc floating:(double)floating;
- (void)addLineWithDescription:(NSString *)desc boolean:(BOOL)boolean;
You can also save the created view by simple calling one of the following methods
- (void)saveDebugView; // will use self.saveUrl and call the following method
- (BOOL)saveDebugViewToUrl:(NSURL *)url;