Permalink
Browse files

Bug fix, code review.

Private member variable names modified to make it clear when they are
used instead of property, bug fix in color property, minor text
formatting, additional checks.  Modified one method to synthesise its
accessor.  This review and commit is in advance of adding / repairing
features.
  • Loading branch information...
1 parent 66c7644 commit 1442f48100be6afb1e3e4ec93c1d3d3753cc0f81 @epreston committed Sep 13, 2011
@@ -356,6 +356,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = PSHTreeGraph_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
GCC_WARN_UNUSED_FUNCTION = YES;
INFOPLIST_FILE = "PSHTreeGraph-Info.plist";
PRODUCT_NAME = PSHTreeGraph;
@@ -371,6 +372,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = PSHTreeGraph_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
GCC_WARN_UNUSED_FUNCTION = YES;
INFOPLIST_FILE = "PSHTreeGraph-Info.plist";
PRODUCT_NAME = PSHTreeGraph;
@@ -409,9 +411,12 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_PARAMETER = NO;
GCC_WARN_UNUSED_VARIABLE = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = 2;
@@ -426,9 +431,12 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_PARAMETER = NO;
GCC_WARN_UNUSED_VARIABLE = YES;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
@@ -22,13 +22,13 @@
{
@private
- UIColor *borderColor;
- CGFloat borderWidth;
- CGFloat cornerRadius;
+ UIColor *_borderColor;
+ CGFloat _borderWidth;
+ CGFloat _cornerRadius;
- UIColor *fillColor;
+ UIColor *_fillColor;
- BOOL showingSelected;
+ BOOL _showingSelected;
}
@@ -44,14 +44,14 @@ - (void) updateLayerAppearanceToMatchContainerView
// CGFloat scaleFactor = [[self window] userSpaceScaleFactor];
CGFloat scaleFactor = 1.0f;
- [layer setBorderWidth:(borderWidth * scaleFactor)];
- if (borderWidth > 0.0f) {
- [layer setBorderColor:[borderColor CGColor]];
+ [layer setBorderWidth:(_borderWidth * scaleFactor)];
+ if (_borderWidth > 0.0f) {
+ [layer setBorderColor:[_borderColor CGColor]];
}
- [layer setCornerRadius:(cornerRadius * scaleFactor)];
+ [layer setCornerRadius:(_cornerRadius * scaleFactor)];
- if ( showingSelected ) {
+ if ( _showingSelected ) {
[layer setBackgroundColor:[[UIColor yellowColor] CGColor] ];
} else {
[layer setBackgroundColor:[[self fillColor] CGColor] ];
@@ -71,11 +71,11 @@ - (void) configureDetaults
// Initialize ivars directly. As a rule, it's best to avoid invoking accessors from an -init...
// method, since they may wrongly expect the instance to be fully formed.
- borderColor = [[UIColor colorWithRed:1.0f green:0.8f blue:0.4f alpha:1.0f] retain];
- borderWidth = 3.0f;
- cornerRadius = 8.0f;
- fillColor = [[UIColor colorWithRed:1.0f green:0.5f blue:0.0f alpha:1.0f] retain];
- showingSelected = NO;
+ _borderColor = [[UIColor colorWithRed:1.0f green:0.8f blue:0.4f alpha:1.0f] retain];
+ _borderWidth = 3.0f;
+ _cornerRadius = 8.0f;
+ _fillColor = [[UIColor colorWithRed:1.0f green:0.5f blue:0.0f alpha:1.0f] retain];
+ _showingSelected = NO;
[self updateLayerAppearanceToMatchContainerView];
}
@@ -98,53 +98,57 @@ - (void) awakeFromNib
#pragma mark - Styling
-@synthesize borderColor;
+@synthesize borderColor = _borderColor;
- (void) setBorderColor:(UIColor *)color
{
- [borderColor release];
- borderColor = [color retain];
- [self updateLayerAppearanceToMatchContainerView];
+ if (_borderColor != color) {
+ [_borderColor release];
+ _borderColor = [color retain];
+ [self updateLayerAppearanceToMatchContainerView];
+ }
}
-@synthesize borderWidth;
+@synthesize borderWidth = _borderWidth;
- (void) setBorderWidth:(CGFloat)width
{
- if (borderWidth != width) {
- borderWidth = width;
+ if (_borderWidth != width) {
+ _borderWidth = width;
[self updateLayerAppearanceToMatchContainerView];
}
}
-@synthesize cornerRadius;
+@synthesize cornerRadius = _cornerRadius;
- (void) setCornerRadius:(CGFloat)radius
{
- if (cornerRadius != radius) {
- cornerRadius = radius;
+ if (_cornerRadius != radius) {
+ _cornerRadius = radius;
[self updateLayerAppearanceToMatchContainerView];
}
}
-@synthesize fillColor;
+@synthesize fillColor = _fillColor;
- (void) setFillColor:(UIColor *)color
{
- [fillColor release];
- fillColor = [[color copy] retain];
- [self updateLayerAppearanceToMatchContainerView];
+ if (_fillColor != color) {
+ [_fillColor release];
+ _fillColor = [color retain];
+ [self updateLayerAppearanceToMatchContainerView];
+ }
}
#pragma mark - Selection State
-@synthesize showingSelected;
+@synthesize showingSelected = _showingSelected;
- (void) setShowingSelected:(BOOL)newShowingSelected
{
- if (showingSelected != newShowingSelected) {
- showingSelected = newShowingSelected;
+ if (_showingSelected != newShowingSelected) {
+ _showingSelected = newShowingSelected;
[self updateLayerAppearanceToMatchContainerView];
}
}
@@ -154,8 +158,8 @@ - (void) setShowingSelected:(BOOL)newShowingSelected
- (void) dealloc
{
- [borderColor release];
- [fillColor release];
+ [_borderColor release];
+ [_fillColor release];
[super dealloc];
}
@@ -29,19 +29,19 @@
@private
// Model
- id <PSTreeGraphModelNode> modelNode; // the model node that nodeView represents
+ id <PSTreeGraphModelNode> _modelNode; // the model node that nodeView represents
// Views
- UIView *nodeView; // the subview of this SubtreeView that shows a representation
+ UIView *_nodeView; // the subview of this SubtreeView that shows a representation
// of the modelNode
- PSBaseBranchView *connectorsView; // the view that shows connections from nodeView to its child nodes
+ PSBaseBranchView *_connectorsView; // the view that shows connections from nodeView to its child nodes
// State
- BOOL expanded; // YES if this subtree is expanded to show its descendants;
+ BOOL _expanded; // YES if this subtree is expanded to show its descendants;
// NO if it's been collapsed to show just its root node
- BOOL needsGraphLayout; // YES if this SubtreeView needs to position its child views
+ BOOL _needsGraphLayout; // YES if this SubtreeView needs to position its child views
// and assess its size; NO if we're sure its layout is up to date
}
Oops, something went wrong.

0 comments on commit 1442f48

Please sign in to comment.