Skip to content

Instantly share code, notes, and snippets.

@lennypham
Created October 23, 2013 18:25
Show Gist options
  • Save lennypham/7123936 to your computer and use it in GitHub Desktop.
Save lennypham/7123936 to your computer and use it in GitHub Desktop.
A UIView category for debugging auto layout issues. Taken from @justin williams presentation on auto layout http://vimeopro.com/360conferences/360idev-2013/video/75232527
#import <objc/objc-runtime.h>
#import "UIView+SGAutoLayoutExtensions.h"
@implementation UIView (SGAutoLayoutExtensions)
#ifdef DEBUG
- (NSString *)nsli_description
{
return [self restorationIdentifier] ?: [NSString stringWithFormat:@"%@:%p", [self class], self];
}
- (BOOL)nsli_descriptionIncludesPointer
{
return [self restorationIdentifier] == nil;
}
- (NSString *)sg_description
{
// Evil!
NSString *string = [self performSelector:@selector(nsli_description)];
if (self.restorationIdentifier != nil)
{
return [string stringByAppendingFormat:@" (%@)", self.restorationIdentifier];
}
return string;
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment