Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: domesticcatsoftware/DCIntrospect
base: master
...
head fork: lxcid/DCIntrospect
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jul 22, 2012
@lxcid lxcid Creates delegation of DCIntrospect and update the demo.
Allows user to extends useful functionality, like keyboard inputs, for their own use cases.
As the project is iOS 4 compatible, delegate property is set as assign, which requires the user to nil the delegate upon deallocation.
It would be better if we can make use of the weak property attribute instead which release the user the responsibility of setting the delegate to nil.
43c338c
View
11 DCIntrospect/DCIntrospect.h
@@ -17,6 +17,8 @@
#ifdef DEBUG
+@protocol DCIntrospectDelegate;
+
@interface UIView (debug)
- (NSString *)recursiveDescription;
@@ -51,6 +53,9 @@
@property (nonatomic) BOOL showingHelp;
+// Weak would have been better but the project is iOS 4 compatible.
+@property (nonatomic, assign) id<DCIntrospectDelegate> delegate;
+
///////////
// Setup //
///////////
@@ -153,3 +158,9 @@
- (BOOL)shouldIgnoreView:(UIView *)view;
@end
+
+@protocol DCIntrospectDelegate <NSObject>
+
+- (BOOL)introspect:(DCIntrospect *)theIntrospect shouldConsumeKeyboardInput:(NSString *)theInput;
+
+@end
View
5 DCIntrospect/DCIntrospect.m
@@ -77,6 +77,7 @@ @implementation DCIntrospect
@synthesize currentView, originalFrame, originalAlpha;
@synthesize currentViewHistory;
@synthesize showingHelp;
+@synthesize delegate;
#pragma mark Setup
@@ -431,6 +432,10 @@ - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range r
return NO;
}
+ if ([self.delegate introspect:self shouldConsumeKeyboardInput:string]) {
+ return NO;
+ }
+
if ([string isEqualToString:kDCIntrospectKeysInvoke])
{
[self invokeIntrospector];
View
3  DCIntrospectDemo/DCIntrospectDemo/DCIntrospectDemoViewController.h
@@ -7,8 +7,9 @@
//
#import <UIKit/UIKit.h>
+#import "DCIntrospect.h"
-@interface DCIntrospectDemoViewController : UIViewController <UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource>
+@interface DCIntrospectDemoViewController : UIViewController <UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource, DCIntrospectDelegate>
{
}
View
17 DCIntrospectDemo/DCIntrospectDemo/DCIntrospectDemoViewController.m
@@ -16,6 +16,8 @@ @implementation DCIntrospectDemoViewController
- (void)dealloc
{
[[DCIntrospect sharedIntrospector] removeNamesForViewsInView:self.view];
+ // It is important for the delegate to be set as nil to prevent crashes.
+ [DCIntrospect sharedIntrospector].delegate = nil;
[activityIndicator release];
[label release];
@@ -33,6 +35,8 @@ - (void)viewDidLoad
{
[super viewDidLoad];
+ [DCIntrospect sharedIntrospector].delegate = self;
+
// set the activity indicator to a non-integer frame for demonstration
self.activityIndicator.frame = CGRectOffset(self.activityIndicator.frame, 0.5, 0.0);
[[DCIntrospect sharedIntrospector] setName:@"activityIndicator" forObject:self.activityIndicator accessedWithSelf:YES];
@@ -108,4 +112,17 @@ - (IBAction)sliderChanged:(id)sender
{
}
+#pragma mark - DCIntrospectDelegate methods
+
+- (BOOL)introspect:(DCIntrospect *)theIntrospect shouldConsumeKeyboardInput:(NSString *)theInput {
+ if ([theInput isEqualToString:@"z"]) {
+ if (self.label.backgroundColor == nil) {
+ self.label.backgroundColor = [UIColor greenColor];
+ } else {
+ self.label.backgroundColor = nil;
+ }
+ }
+ return NO;
+}
+
@end

No commit comments for this range

Something went wrong with that request. Please try again.