diff --git a/DCIntrospect/DCCrossHairView.h b/DCIntrospect/DCCrossHairView.h old mode 100644 new mode 100755 index 7160ffa..2cf6159 --- a/DCIntrospect/DCCrossHairView.h +++ b/DCIntrospect/DCCrossHairView.h @@ -9,7 +9,7 @@ { } -@property (nonatomic, retain) UIColor *color; +@property (nonatomic, strong) UIColor *color; - (id)initWithFrame:(CGRect)frame color:(UIColor *)aColor; diff --git a/DCIntrospect/DCCrossHairView.m b/DCIntrospect/DCCrossHairView.m old mode 100644 new mode 100755 index cc1c989..6b73d4c --- a/DCIntrospect/DCCrossHairView.m +++ b/DCIntrospect/DCCrossHairView.m @@ -9,11 +9,7 @@ @implementation DCCrossHairView @synthesize color; -- (void)dealloc -{ - [color release]; - [super dealloc]; -} + - (id)initWithFrame:(CGRect)frame color:(UIColor *)aColor { @@ -38,6 +34,7 @@ - (void)drawRect:(CGRect)rect CGContextMoveToPoint(context, 0, floorf(self.bounds.size.height / 2.0f) + 0.5f); CGContextAddLineToPoint(context, self.bounds.size.width, floorf(self.bounds.size.height / 2.0f) + 0.5f); CGContextStrokePath(context); + } @end diff --git a/DCIntrospect/DCFrameView.h b/DCIntrospect/DCFrameView.h old mode 100644 new mode 100755 index 393f9b6..49169b3 --- a/DCIntrospect/DCFrameView.h +++ b/DCIntrospect/DCFrameView.h @@ -23,9 +23,9 @@ @property (nonatomic, assign) id delegate; @property (nonatomic) CGRect mainRect; @property (nonatomic) CGRect superRect; -@property (nonatomic, retain) UILabel *touchPointLabel; -@property (nonatomic, retain) NSMutableArray *rectsToOutline; -@property (nonatomic, retain) DCCrossHairView *touchPointView; +@property (nonatomic, strong) UILabel *touchPointLabel; +@property (nonatomic, strong) NSMutableArray *rectsToOutline; +@property (nonatomic, strong) DCCrossHairView *touchPointView; /////////// // Setup // diff --git a/DCIntrospect/DCFrameView.m b/DCIntrospect/DCFrameView.m old mode 100644 new mode 100755 index 040fcd9..6a5c128 --- a/DCIntrospect/DCFrameView.m +++ b/DCIntrospect/DCFrameView.m @@ -16,10 +16,6 @@ @implementation DCFrameView - (void)dealloc { self.delegate = nil; - [touchPointLabel release]; - [touchPointView release]; - - [super dealloc]; } #pragma mark - Setup @@ -33,10 +29,10 @@ - (id)initWithFrame:(CGRect)frame delegate:(id)aDelegate self.backgroundColor = [UIColor clearColor]; self.opaque = NO; - self.touchPointLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease]; + self.touchPointLabel = [[UILabel alloc] initWithFrame:CGRectZero]; self.touchPointLabel.text = @"X 320 Y 480"; self.touchPointLabel.font = [UIFont boldSystemFontOfSize:12.0f]; - self.touchPointLabel.textAlignment = UITextAlignmentCenter; + self.touchPointLabel.textAlignment = NSTextAlignmentCenter; self.touchPointLabel.textColor = [UIColor whiteColor]; self.touchPointLabel.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.65f]; self.touchPointLabel.layer.cornerRadius = 5.5f; @@ -46,7 +42,7 @@ - (id)initWithFrame:(CGRect)frame delegate:(id)aDelegate self.rectsToOutline = [NSMutableArray array]; - self.touchPointView = [[[DCCrossHairView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 17.0f, 17.0f) color:[UIColor blueColor]] autorelease]; + self.touchPointView = [[DCCrossHairView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 17.0f, 17.0f) color:[UIColor blueColor]]; self.touchPointView.alpha = 0.0f; [self addSubview:self.touchPointView]; } @@ -121,7 +117,7 @@ - (void)drawRect:(CGRect)rect UIFont *font = [UIFont systemFontOfSize:10.0f]; - float dash[2] = {3, 3}; + CGFloat dash[2] = {3, 3}; CGContextSetLineDash(context, 0, dash, 2); // edge->left side diff --git a/DCIntrospect/DCIntrospect.h b/DCIntrospect/DCIntrospect.h old mode 100644 new mode 100755 index f7178bc..55c4921 --- a/DCIntrospect/DCIntrospect.h +++ b/DCIntrospect/DCIntrospect.h @@ -31,23 +31,23 @@ @property (nonatomic) BOOL keyboardBindingsOn; // default: YES @property (nonatomic) BOOL showStatusBarOverlay; // default: YES -@property (nonatomic, retain) UIGestureRecognizer *invokeGestureRecognizer; // default: nil +@property (nonatomic, strong) UIGestureRecognizer *invokeGestureRecognizer; // default: nil @property (nonatomic) BOOL on; @property (nonatomic) BOOL handleArrowKeys; @property (nonatomic) BOOL viewOutlines; @property (nonatomic) BOOL highlightNonOpaqueViews; @property (nonatomic) BOOL flashOnRedraw; -@property (nonatomic, retain) DCFrameView *frameView; -@property (nonatomic, retain) UITextView *inputTextView; -@property (nonatomic, retain) DCStatusBarOverlay *statusBarOverlay; +@property (nonatomic, strong) DCFrameView *frameView; +@property (nonatomic, strong) UITextView *inputTextView; +@property (nonatomic, strong) DCStatusBarOverlay *statusBarOverlay; -@property (nonatomic, retain) NSMutableDictionary *objectNames; +@property (nonatomic, strong) NSMutableDictionary *objectNames; @property (nonatomic, assign) UIView *currentView; @property (nonatomic) CGRect originalFrame; @property (nonatomic) CGFloat originalAlpha; -@property (nonatomic, retain) NSMutableArray *currentViewHistory; +@property (nonatomic, strong) NSMutableArray *currentViewHistory; @property (nonatomic) BOOL showingHelp; @@ -87,7 +87,7 @@ - (void)logCodeForCurrentViewChanges; -// make sure all names that are added are removed at dealloc or else they will be retained here! +// make sure all names that are added are removed at dealloc or else they will be stronged here! - (void)setName:(NSString *)name forObject:(id)object accessedWithSelf:(BOOL)accessedWithSelf; - (NSString *)nameForObject:(id)object; - (void)removeNamesForViewsInView:(UIView *)view; diff --git a/DCIntrospect/DCIntrospect.m b/DCIntrospect/DCIntrospect.m old mode 100644 new mode 100755 index cc4b4cf..0cb1d8b --- a/DCIntrospect/DCIntrospect.m +++ b/DCIntrospect/DCIntrospect.m @@ -82,29 +82,29 @@ @implementation DCIntrospect + (void)load { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSString *simulatorRoot = [[[NSProcessInfo processInfo] environment] objectForKey:@"IPHONE_SIMULATOR_ROOT"]; - if (simulatorRoot) - { - void *AppSupport = dlopen([[simulatorRoot stringByAppendingPathComponent:@"/System/Library/PrivateFrameworks/AppSupport.framework/AppSupport"] fileSystemRepresentation], RTLD_LAZY); - CFStringRef (*CPCopySharedResourcesPreferencesDomainForDomain)(CFStringRef domain) = (CFStringRef (*)())dlsym(AppSupport, "CPCopySharedResourcesPreferencesDomainForDomain"); - if (CPCopySharedResourcesPreferencesDomainForDomain) - { - CFStringRef accessibilityDomain = CPCopySharedResourcesPreferencesDomainForDomain(CFSTR("com.apple.Accessibility")); - if (accessibilityDomain) - { - // This must be done *before* UIApplicationMain, hence +load - CFPreferencesSetValue(CFSTR("ApplicationAccessibilityEnabled"), kCFBooleanTrue, accessibilityDomain, kCFPreferencesAnyUser, kCFPreferencesAnyHost); - CFRelease(accessibilityDomain); - } - } - } - - [pool drain]; + @autoreleasepool{ + NSString *simulatorRoot = [[[NSProcessInfo processInfo] environment] objectForKey:@"IPHONE_SIMULATOR_ROOT"]; + if (simulatorRoot) + { + void *AppSupport = dlopen([[simulatorRoot stringByAppendingPathComponent:@"/System/Library/PrivateFrameworks/AppSupport.framework/AppSupport"] fileSystemRepresentation], RTLD_LAZY); + CFStringRef (*CPCopySharedResourcesPreferencesDomainForDomain)(CFStringRef domain) = (CFStringRef (*)())dlsym(AppSupport, "CPCopySharedResourcesPreferencesDomainForDomain"); + if (CPCopySharedResourcesPreferencesDomainForDomain) + { + CFStringRef accessibilityDomain = CPCopySharedResourcesPreferencesDomainForDomain(CFSTR("com.apple.Accessibility")); + if (accessibilityDomain) + { + // This must be done *before* UIApplicationMain, hence +load + CFPreferencesSetValue(CFSTR("ApplicationAccessibilityEnabled"), kCFBooleanTrue, accessibilityDomain, kCFPreferencesAnyUser, kCFPreferencesAnyHost); + CFRelease(accessibilityDomain); + } + } + } + } } static void *originalValueForKeyIMPKey = &originalValueForKeyIMPKey; +typedef id (* _rIMP)(id,SEL ,...); id UITextInputTraits_valueForKey(id self, SEL _cmd, NSString *key); id UITextInputTraits_valueForKey(id self, SEL _cmd, NSString *key) @@ -125,14 +125,15 @@ id UITextInputTraits_valueForKey(id self, SEL _cmd, NSString *key) } IMP valueForKey = (IMP)[objc_getAssociatedObject([self class], originalValueForKeyIMPKey) pointerValue]; + _rIMP func = (_rIMP)valueForKey; if ([textInputTraitsProperties containsObject:key]) { - id textInputTraits = valueForKey(self, _cmd, @"textInputTraits"); - return valueForKey(textInputTraits, _cmd, key); + id textInputTraits = func(self, _cmd, @"textInputTraits"); + return func(textInputTraits, _cmd, key); } else { - return valueForKey(self, _cmd, key); + return func(self, _cmd, key); } } @@ -186,16 +187,16 @@ - (void)start if (!self.statusBarOverlay) { - self.statusBarOverlay = [[[DCStatusBarOverlay alloc] init] autorelease]; + self.statusBarOverlay = [[DCStatusBarOverlay alloc] init] ; } if (!self.inputTextView) { - self.inputTextView = [[[UITextView alloc] initWithFrame:CGRectZero] autorelease]; + self.inputTextView = [[UITextView alloc] initWithFrame:CGRectZero]; self.inputTextView.delegate = self; self.inputTextView.autocorrectionType = UITextAutocorrectionTypeNo; self.inputTextView.autocapitalizationType = UITextAutocapitalizationTypeNone; - self.inputTextView.inputView = [[[UIView alloc] init] autorelease]; + self.inputTextView.inputView = [[UIView alloc] init]; self.inputTextView.scrollsToTop = NO; [mainWindow addSubview:self.inputTextView]; } @@ -236,7 +237,7 @@ - (void)start [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateViews) name:UIDeviceOrientationDidChangeNotification object:nil]; if (!self.currentViewHistory) - self.currentViewHistory = [[[NSMutableArray alloc] init] autorelease]; + self.currentViewHistory = [[NSMutableArray alloc] init]; NSLog(@"DCIntrospect is setup. %@ to start.", [kDCIntrospectKeysInvoke isEqualToString:@" "] ? @"Push the space bar" : [NSString stringWithFormat:@"Type '%@'", kDCIntrospectKeysInvoke]); } @@ -261,9 +262,8 @@ - (void)setInvokeGestureRecognizer:(UIGestureRecognizer *)newGestureRecognizer UIWindow *mainWindow = [self mainWindow]; [mainWindow removeGestureRecognizer:invokeGestureRecognizer]; - [invokeGestureRecognizer release]; invokeGestureRecognizer = nil; - invokeGestureRecognizer = [newGestureRecognizer retain]; + invokeGestureRecognizer = newGestureRecognizer; [invokeGestureRecognizer addTarget:self action:@selector(invokeIntrospector)]; [mainWindow addGestureRecognizer:invokeGestureRecognizer]; } @@ -621,7 +621,7 @@ - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range r UIView *view = self.currentView; view.tag = view.tag; // suppress the xcode warning about an unused variable. NSLog(@"DCIntrospect: access current view using local 'view' variable."); - DEBUGGER; +// DEBUGGER; return NO; } @@ -659,10 +659,12 @@ - (void)logCodeForCurrentViewChanges [outputString appendFormat:@"%@.alpha = %.2f;\n", varName, self.currentView.alpha]; } - if (outputString.length == 0) - NSLog(@"DCIntrospect: No changes made to %@.", self.currentView.class); - else - printf("\n\n%s\n", [outputString UTF8String]); + if (outputString.length == 0){ + NSLog(@"DCIntrospect: No changes made to %@.", self.currentView.class); + }else{ + printf("\n\n%s\n", [outputString UTF8String]); + } + } - (void)setName:(NSString *)name forObject:(id)object accessedWithSelf:(BOOL)accessedWithSelf @@ -730,7 +732,7 @@ - (void)updateFrameView UIWindow *mainWindow = [self mainWindow]; if (!self.frameView) { - self.frameView = [[[DCFrameView alloc] initWithFrame:(CGRect){ CGPointZero, mainWindow.frame.size } delegate:self] autorelease]; + self.frameView = [[DCFrameView alloc] initWithFrame:(CGRect){ CGPointZero, mainWindow.frame.size } delegate:self]; [mainWindow addSubview:self.frameView]; self.frameView.alpha = 0.0f; [self updateViews]; @@ -774,7 +776,7 @@ - (void)updateStatusBar nameForObject = [nameForObject substringFromIndex:@"self.".length]; if (self.currentView.tag != 0) - self.statusBarOverlay.leftLabel.text = [NSString stringWithFormat:@"%@ (tag: %i)", nameForObject, self.currentView.tag]; + self.statusBarOverlay.leftLabel.text = [NSString stringWithFormat:@"%@ (tag: %zd)", nameForObject, self.currentView.tag]; else self.statusBarOverlay.leftLabel.text = [NSString stringWithFormat:@"%@", nameForObject]; @@ -1294,13 +1296,13 @@ - (void)toggleHelp { self.statusBarOverlay.leftLabel.text = @"Help"; self.statusBarOverlay.rightLabel.text = @"Any key to close"; - UIView *backingView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, mainWindow.frame.size.width, mainWindow.frame.size.height)] autorelease]; + UIView *backingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, mainWindow.frame.size.width, mainWindow.frame.size.height)]; backingView.tag = 1548; backingView.alpha = 0; backingView.backgroundColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.85f]; [mainWindow addSubview:backingView]; - UIWebView *webView = [[[UIWebView alloc] initWithFrame:backingView.frame] autorelease]; + UIWebView *webView = [[UIWebView alloc] initWithFrame:backingView.frame]; webView.opaque = NO; webView.backgroundColor = [UIColor clearColor]; webView.delegate = self; @@ -1560,7 +1562,7 @@ - (NSArray *)subclassesOfClass:(Class)parentClass int numClasses = objc_getClassList(NULL, 0); Class *classes = NULL; - classes = malloc(sizeof(Class) * numClasses); + classes = (Class *)malloc(sizeof(Class) * numClasses); numClasses = objc_getClassList(classes, numClasses); NSMutableArray *result = [NSMutableArray array]; @@ -1616,7 +1618,7 @@ - (NSMutableArray *)viewsAtPoint:(CGPoint)touchPoint inView:(UIView *)view } } - return [views autorelease]; + return views; } - (void)fadeView:(UIView *)view toAlpha:(CGFloat)alpha diff --git a/DCIntrospect/DCIntrospectSettings.h b/DCIntrospect/DCIntrospectSettings.h old mode 100644 new mode 100755 diff --git a/DCIntrospect/DCStatusBarOverlay.h b/DCIntrospect/DCStatusBarOverlay.h old mode 100644 new mode 100755 index cd30a44..462585d --- a/DCIntrospect/DCStatusBarOverlay.h +++ b/DCIntrospect/DCStatusBarOverlay.h @@ -15,8 +15,8 @@ { } -@property (nonatomic, retain) UILabel *leftLabel; -@property (nonatomic, retain) UILabel *rightLabel; +@property (nonatomic, strong) UILabel *leftLabel; +@property (nonatomic, strong) UILabel *rightLabel; /////////// // Setup // diff --git a/DCIntrospect/DCStatusBarOverlay.m b/DCIntrospect/DCStatusBarOverlay.m old mode 100644 new mode 100755 index 7be771e..b879391 --- a/DCIntrospect/DCStatusBarOverlay.m +++ b/DCIntrospect/DCStatusBarOverlay.m @@ -13,10 +13,6 @@ - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; - [leftLabel release]; - [rightLabel release]; - - [super dealloc]; } #pragma mark Setup @@ -39,25 +35,24 @@ - (id)init UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:self.frame]; backgroundImageView.image = [[UIImage imageNamed:@"statusBarBackground.png"] stretchableImageWithLeftCapWidth:2.0f topCapHeight:0.0f]; [self addSubview:backgroundImageView]; - [backgroundImageView release]; - self.leftLabel = [[[UILabel alloc] initWithFrame:CGRectOffset(self.frame, 2.0f, 0.0f)] autorelease]; + self.leftLabel = [[UILabel alloc] initWithFrame:CGRectOffset(self.frame, 2.0f, 0.0f)]; self.leftLabel.backgroundColor = [UIColor clearColor]; - self.leftLabel.textAlignment = UITextAlignmentLeft; + self.leftLabel.textAlignment = NSTextAlignmentLeft; self.leftLabel.font = [UIFont boldSystemFontOfSize:12.0f]; self.leftLabel.textColor = [UIColor colorWithWhite:0.97f alpha:1.0f]; self.leftLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; [self addSubview:self.leftLabel]; - self.rightLabel = [[[UILabel alloc] initWithFrame:CGRectOffset(self.frame, -2.0f, 0.0f)] autorelease]; + self.rightLabel = [[UILabel alloc] initWithFrame:CGRectOffset(self.frame, -2.0f, 0.0f)]; self.rightLabel.backgroundColor = [UIColor clearColor]; self.rightLabel.font = [UIFont boldSystemFontOfSize:12.0f]; - self.rightLabel.textAlignment = UITextAlignmentRight; + self.rightLabel.textAlignment = NSTextAlignmentRight; self.rightLabel.textColor = [UIColor colorWithWhite:0.9f alpha:1.0f]; self.rightLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; [self addSubview:self.rightLabel]; - UITapGestureRecognizer *gestureRecognizer = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped)] autorelease]; + UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped)] ; [self addGestureRecognizer:gestureRecognizer]; [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];