-
Notifications
You must be signed in to change notification settings - Fork 265
Open
Description
To make it easier to read debug logs, add this category and make it so that when you tap on a view, it displays the tag name along with the class name. Also, the debug output should display these tags.
e.g.
[myview setNametag:@"My main view"]
when you tap on it, DCIntrospect should display "UIView - My main view {{0,0},{320,568}}" on the top status bar. Without this, you would only see "UIView" which is not helpful when you have many views and subviews!
Category code:
@interface UIView (NameTags)
- (NSString *)nametag;
- (void)setNametag:(NSString *)theNametag;
- (NSString *)objectIdentifier;
@EnD
@implementation UIView (NameTags)
- (NSString *)nametag {
return (NSString *)objc_getAssociatedObject(self, @selector(nametag));
}
// Nametag setter
- (void)setNametag:(NSString *)theNametag {
objc_setAssociatedObject(self, @selector(nametag), theNametag, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
// Return 'Class description : hex memory address'
- (NSString *)objectIdentifier {
return [NSString stringWithFormat:@"%@:0x%0x", self.class.description, (int) self];
}
Metadata
Metadata
Assignees
Labels
No labels