Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
Merge branch 'ARC'
Browse files Browse the repository at this point in the history
  • Loading branch information
epreston committed Oct 13, 2013
2 parents 54ce784 + 1d5eefb commit e7ac7ce
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 121 deletions.
6 changes: 0 additions & 6 deletions Example 1/Classes/Controller/PSHTreeGraphAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:

#pragma mark - Resouce Management

- (void) dealloc
{
[viewController_ release];
[window_ release];
[super dealloc];
}


@end
2 changes: 1 addition & 1 deletion Example 1/Classes/Controller/PSHTreeGraphViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@interface PSHTreeGraphViewController : UIViewController <PSTreeGraphDelegate>

// The TreeGraph
@property(nonatomic, assign) IBOutlet PSBaseTreeGraphView *treeGraphView;
@property(nonatomic, weak) IBOutlet PSBaseTreeGraphView *treeGraphView;

// The name of the root class that the TreeGraph is currently showing.
@property(nonatomic, copy) NSString *rootClassName;
Expand Down
8 changes: 1 addition & 7 deletions Example 1/Classes/Controller/PSHTreeGraphViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ @interface PSHTreeGraphViewController ()
{

@private
PSBaseTreeGraphView *treeGraphView_;
PSBaseTreeGraphView *__weak treeGraphView_;
NSString *rootClassName_;
}

Expand All @@ -41,7 +41,6 @@ - (void) setRootClassName:(NSString *)newRootClassName
NSParameterAssert(newRootClassName != nil);

if (![rootClassName_ isEqualToString:newRootClassName]) {
[rootClassName_ release];
rootClassName_ = [newRootClassName copy];

treeGraphView_.treeGraphOrientation = PSTreeGraphOrientationStyleHorizontalFlipped;
Expand Down Expand Up @@ -129,10 +128,5 @@ - (void) viewDidUnload
// e.g. self.myOutlet = nil;
}

- (void) dealloc
{
[rootClassName_ release];
[super dealloc];
}

@end
6 changes: 3 additions & 3 deletions Example 1/Classes/Model/ObjCClass/ObjCClassWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@

/// The wrappedClass' name (e.g. @"UIControl" or @"CALayer" or "CAAnimation")

@property (nonatomic, readonly) NSString *name;
@property (weak, nonatomic, readonly) NSString *name;


/// An ObjCClassWrapper representing the wrappedClass' superclass.

@property (nonatomic, readonly) ObjCClassWrapper *superclassWrapper;
@property (weak, nonatomic, readonly) ObjCClassWrapper *superclassWrapper;


/// An array of ObjCClassWrappers representing the wrappedClass' subclasses.
/// (For convenience, the subclasses are sorted by name.)

@property (nonatomic, readonly) NSArray *subclasses;
@property (weak, nonatomic, readonly) NSArray *subclasses;


/// The wrappedClass' intrinsic instance size (which doesn't include external/auxiliary storage).
Expand Down
12 changes: 3 additions & 9 deletions Example 1/Classes/Model/ObjCClass/ObjCClassWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ @implementation ObjCClassWrapper

- (id) copyWithZone:(NSZone *)zone
{
return [self retain];
return self;
}


Expand All @@ -55,11 +55,10 @@ - (id) copyWithZone:(NSZone *)zone
if (aClass != Nil) {
wrappedClass = aClass;
if (classToWrapperMapTable == nil) {
classToWrapperMapTable = [[NSMutableDictionary dictionaryWithCapacity:16] retain];
classToWrapperMapTable = [NSMutableDictionary dictionaryWithCapacity:16];
}
classToWrapperMapTable[(id<NSCopying>)wrappedClass] = self;
} else {
[self release];
return nil;
}
}
Expand All @@ -70,7 +69,7 @@ + (ObjCClassWrapper *) wrapperForClass:(Class)aClass
{
ObjCClassWrapper *wrapper = classToWrapperMapTable[aClass];
if (wrapper == nil) {
wrapper = [[[self alloc] initWithWrappedClass:aClass] autorelease];
wrapper = [[self alloc] initWithWrappedClass:aClass];
}
return wrapper;
}
Expand Down Expand Up @@ -150,10 +149,5 @@ - (NSArray *) childModelNodes

#pragma mark - Resource Management

- (void) dealloc
{
[subclassesCache release];
[super dealloc];
}

@end
6 changes: 3 additions & 3 deletions Example 1/Classes/View/MyLeafView.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

@interface MyLeafView : PSBaseLeafView

@property (nonatomic, assign) IBOutlet UIButton *expandButton;
@property (nonatomic, assign) IBOutlet UILabel *titleLabel;
@property (nonatomic, assign) IBOutlet UILabel *detailLabel;
@property (nonatomic, weak) IBOutlet UIButton *expandButton;
@property (nonatomic, weak) IBOutlet UILabel *titleLabel;
@property (nonatomic, weak) IBOutlet UILabel *detailLabel;

@end
13 changes: 3 additions & 10 deletions Example 1/Classes/View/MyLeafView.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ @interface MyLeafView ()

@private
// Interface
UIButton *expandButton_;
UILabel *titleLabel_;
UILabel *detailLabel_;
UIButton *__weak expandButton_;
UILabel *__weak titleLabel_;
UILabel *__weak detailLabel_;
}

@end
Expand Down Expand Up @@ -53,11 +53,4 @@ - (id) initWithCoder:(NSCoder *)decoder
}


#pragma mark - Resource Management

- (void) dealloc
{
[super dealloc];
}

@end
6 changes: 0 additions & 6 deletions Example 1/Classes/View/MyTreeGraphView.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,5 @@ - (id) initWithCoder:(NSCoder *)decoder
return self;
}

#pragma mark - Resource Management

- (void) dealloc
{
[super dealloc];
}

@end
4 changes: 4 additions & 0 deletions Example 1/PSHTreeGraph.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
32CA4F630368D1EE00C91783 /* PSHTreeGraph_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSHTreeGraph_Prefix.pch; sourceTree = "<group>"; };
4F0E109E1407EB94009B9214 /* Doxyfile */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; name = Doxyfile; path = ../Doxyfile; sourceTree = "<group>"; };
4F0EE31B15D2F99B009BC883 /* PSTreeGraphDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PSTreeGraphDelegate.h; sourceTree = "<group>"; };
4F2A233D180B3AEB00778BA1 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = text; name = README.md; path = ../README.md; sourceTree = "<group>"; wrapsLines = 1; };
4F3536F311FC851F00AABFF1 /* MyTreeGraphView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MyTreeGraphView.h; path = Classes/View/MyTreeGraphView.h; sourceTree = SOURCE_ROOT; };
4F3536F411FC851F00AABFF1 /* MyTreeGraphView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MyTreeGraphView.m; path = Classes/View/MyTreeGraphView.m; sourceTree = SOURCE_ROOT; };
4F35379511FC8EC900AABFF1 /* PSBaseBranchView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSBaseBranchView.h; path = ../PSTreeGraphView/PSBaseBranchView.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -119,6 +120,7 @@
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
isa = PBXGroup;
children = (
4F2A233D180B3AEB00778BA1 /* README.md */,
4F0E109E1407EB94009B9214 /* Doxyfile */,
32CA4F630368D1EE00C91783 /* PSHTreeGraph_Prefix.pch */,
29B97316FDCFA39411CA2CEA /* main.m */,
Expand Down Expand Up @@ -351,6 +353,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_ENTITLEMENTS = Entitlements.plist;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
Expand All @@ -370,6 +373,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_ENTITLEMENTS = Entitlements.plist;
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down
2 changes: 1 addition & 1 deletion PSTreeGraphView/PSBaseBranchView.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
/// @note The getter for this is a convenience method that ascends the view tree
/// until it encounters a TreeGraph.

@property (nonatomic, readonly) PSBaseTreeGraphView *enclosingTreeGraph;
@property (weak, nonatomic, readonly) PSBaseTreeGraphView *enclosingTreeGraph;

@end
6 changes: 3 additions & 3 deletions PSTreeGraphView/PSBaseLeafView.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#pragma mark - Styling

/// The color of the ContainerView's stroked border.
@property (nonatomic, retain) UIColor *borderColor;
@property (nonatomic, strong) UIColor *borderColor;

/// The width of the ContainerView's stroked border. May be zero.
@property (nonatomic, assign) CGFloat borderWidth;
Expand All @@ -32,10 +32,10 @@
@property (nonatomic, assign) CGFloat cornerRadius;

/// The fill color for the ContainerView's interior.
@property (nonatomic, retain) UIColor *fillColor;
@property (nonatomic, strong) UIColor *fillColor;

/// The fill color for the ContainerView's interior when selected.
@property (nonatomic, retain) UIColor *selectionColor;
@property (nonatomic, strong) UIColor *selectionColor;


#pragma mark - Selection State
Expand Down
33 changes: 9 additions & 24 deletions PSTreeGraphView/PSBaseLeafView.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ @implementation PSBaseLeafView
- (void) setBorderColor:(UIColor *)color
{
if (borderColor_ != color) {
[borderColor_ release];
borderColor_ = [color retain];
borderColor_ = color;
[self updateLayerAppearanceToMatchContainerView];
}
}
Expand Down Expand Up @@ -80,8 +79,7 @@ - (void) setCornerRadius:(CGFloat)radius
- (void) setFillColor:(UIColor *)color
{
if (fillColor_ != color) {
[fillColor_ release];
fillColor_ = [color retain];
fillColor_ = color;
[self updateLayerAppearanceToMatchContainerView];
}
}
Expand All @@ -91,8 +89,7 @@ - (void) setFillColor:(UIColor *)color
- (void) setSelectionColor:(UIColor *)color
{
if (selectionColor_ != color) {
[selectionColor_ release];
selectionColor_ = [color retain];
selectionColor_ = color;
[self updateLayerAppearanceToMatchContainerView];
}
}
Expand Down Expand Up @@ -156,27 +153,15 @@ - (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.0 green:0.8 blue:0.4 alpha:1.0] retain];
borderColor_ = [UIColor colorWithRed:1.0 green:0.8 blue:0.4 alpha:1.0];
borderWidth_ = 3.0;
cornerRadius_ = 8.0;
fillColor_ = [[UIColor colorWithRed:1.0 green:0.5 blue:0.0 alpha:1.0] retain];
selectionColor_ = [[UIColor colorWithRed:1.0 green:1.0 blue:0.0 alpha:1.0] retain];
fillColor_ = [UIColor colorWithRed:1.0 green:0.5 blue:0.0 alpha:1.0];
selectionColor_ = [UIColor colorWithRed:1.0 green:1.0 blue:0.0 alpha:1.0];
showingSelected_ = NO;
}


#pragma mark - Resource Management

- (void) dealloc
{
[borderColor_ release];
[fillColor_ release];
[selectionColor_ release];

[super dealloc];
}


#pragma mark - UIView

- initWithFrame:(CGRect)newFrame
Expand Down Expand Up @@ -211,15 +196,15 @@ - (id) initWithCoder:(NSCoder *)decoder
[self configureDetaults];

if ([decoder containsValueForKey:@"borderColor"])
borderColor_ = [[decoder decodeObjectForKey:@"borderColor"] retain];
borderColor_ = [decoder decodeObjectForKey:@"borderColor"];
if ([decoder containsValueForKey:@"borderWidth"])
borderWidth_ = [decoder decodeFloatForKey:@"borderWidth"];
if ([decoder containsValueForKey:@"cornerRadius"])
cornerRadius_ = [decoder decodeFloatForKey:@"cornerRadius"];
if ([decoder containsValueForKey:@"fillColor"])
fillColor_ = [[decoder decodeObjectForKey:@"fillColor"] retain];
fillColor_ = [decoder decodeObjectForKey:@"fillColor"];
if ([decoder containsValueForKey:@"selectionColor"])
selectionColor_ = [[decoder decodeObjectForKey:@"selectionColor"] retain];
selectionColor_ = [decoder decodeObjectForKey:@"selectionColor"];
if ([decoder containsValueForKey:@"showingSelected"])
showingSelected_ = [decoder decodeBoolForKey:@"showingSelected"];

Expand Down
4 changes: 2 additions & 2 deletions PSTreeGraphView/PSBaseSubtreeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@

/// The view that represents the modelNode. Is a subview of SubtreeView, and may itself have descendant views.

@property (nonatomic, assign) IBOutlet UIView *nodeView;
@property (nonatomic, weak) IBOutlet UIView *nodeView;

/// Link to the enclosing TreeGraph. (The getter for this is a convenience method that ascends
/// the view tree until it encounters a TreeGraph.)

@property (nonatomic, readonly) PSBaseTreeGraphView *enclosingTreeGraph;
@property (weak, nonatomic, readonly) PSBaseTreeGraphView *enclosingTreeGraph;

// Whether the model node represented by this SubtreeView is a leaf node (one without child nodes). This
// can be a useful property to bind user interface state to. In the TreeGraph demo app, for example,
Expand Down
18 changes: 3 additions & 15 deletions PSTreeGraphView/PSBaseSubtreeView.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ @interface PSBaseSubtreeView ()
id <PSTreeGraphModelNode> modelNode_; // the model node that nodeView represents

// Views
UIView *nodeView_; // the subview of this SubtreeView that shows a representation
UIView *__weak 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
Expand Down Expand Up @@ -163,17 +163,6 @@ - (PSBaseTreeGraphView *) enclosingTreeGraph
return nil;
}

#pragma mark - Resource Management

- (void) dealloc
{
// [nodeView release]; // not retained, since an IBOutlet
[connectorsView_ release];
[modelNode_ release];

[super dealloc];
}


#pragma mark - Layout

Expand Down Expand Up @@ -201,8 +190,8 @@ - (void) flipTreeGraph
{
// Recurse for descendant SubtreeViews.
CGFloat myWidth = self.frame.size.width;
CGFloat myHeight = self.frame.size.height;
PSBaseTreeGraphView *treeGraph = [self enclosingTreeGraph];
CGFloat myHeight = self.frame.size.height;
PSBaseTreeGraphView *treeGraph = [self enclosingTreeGraph];
PSTreeGraphOrientationStyle treeOrientation = [treeGraph treeGraphOrientation];

NSArray *subviews = [self subviews];
Expand All @@ -225,7 +214,6 @@ - (void) flipTreeGraph
}
}


- (CGSize) layoutGraphIfNeeded
{
// Return early if layout not needed
Expand Down
Loading

0 comments on commit e7ac7ce

Please sign in to comment.