Skip to content
Browse files

Adopt New Language Features in Xcode 4.2

A few new language features have been released with 4.2. This commit
updates the codebase to adopt @autoreleasepool language extension and
instance variable hiding.
  • Loading branch information...
1 parent 5da02ce commit 02883f8b88d61186b775a1066d108fbd413bf02b @epreston committed Dec 1, 2011
View
9 Example 1/Classes/Controller/PSHTreeGraphAppDelegate.h
@@ -11,13 +11,10 @@
@class PSHTreeGraphViewController;
-@interface PSHTreeGraphAppDelegate : NSObject <UIApplicationDelegate> {
- UIWindow *window_;
- PSHTreeGraphViewController *viewController_;
-}
+@interface PSHTreeGraphAppDelegate : UIResponder <UIApplicationDelegate>
-@property (nonatomic, retain) IBOutlet UIWindow *window;
-@property (nonatomic, retain) IBOutlet PSHTreeGraphViewController *viewController;
+@property (nonatomic, strong) IBOutlet UIWindow *window;
+@property (nonatomic, strong) IBOutlet PSHTreeGraphViewController *viewController;
@end
View
11 Example 1/Classes/Controller/PSHTreeGraphAppDelegate.m
@@ -11,6 +11,17 @@
#import "PSHTreeGraphViewController.h"
+@interface PSHTreeGraphAppDelegate ()
+{
+
+@private
+ UIWindow *window_;
+ PSHTreeGraphViewController *viewController_;
+}
+
+@end
+
+
@implementation PSHTreeGraphAppDelegate
View
8 Example 1/Classes/Controller/PSHTreeGraphViewController.h
@@ -13,20 +13,14 @@
@class PSBaseTreeGraphView;
-@interface PSHTreeGraphViewController : UIViewController <PSTreeGraphDelegate>
-{
-@private
- PSBaseTreeGraphView *treeGraphView_;
- NSString *rootClassName_;
-}
+@interface PSHTreeGraphViewController : UIViewController <PSTreeGraphDelegate>
// The TreeGraph
@property(nonatomic, assign) IBOutlet PSBaseTreeGraphView *treeGraphView;
// The name of the root class that the TreeGraph is currently showing.
@property(nonatomic, copy) NSString *rootClassName;
-
@end
View
11 Example 1/Classes/Controller/PSHTreeGraphViewController.m
@@ -15,6 +15,17 @@
#import "ObjCClassWrapper.h"
+@interface PSHTreeGraphViewController ()
+{
+
+@private
+ PSBaseTreeGraphView *treeGraphView_;
+ NSString *rootClassName_;
+}
+
+@end
+
+
@implementation PSHTreeGraphViewController
View
6 Example 1/Classes/Model/ObjCClass/ObjCClassWrapper.h
@@ -15,10 +15,6 @@
// the PSTreeGraphModelNode protocol, so that we can use these as model nodes with a TreeGraph.
@interface ObjCClassWrapper : NSObject <PSTreeGraphModelNode, NSCopying>
-{
- Class wrappedClass;
- NSMutableArray *subclassesCache;
-}
#pragma mark - Creating Instances
@@ -36,7 +32,7 @@
#pragma mark - Property Accessors
-// The wrappedClass' name (e.g. @"UIButton")
+// The wrappedClass' name (e.g. @"UIButton" or @"CALayer")
@property (nonatomic, readonly) NSString *name;
View
10 Example 1/Classes/Model/ObjCClass/ObjCClassWrapper.m
@@ -24,6 +24,16 @@ static NSInteger CompareClassNames(id classA, id classB, void* context)
}
+@interface ObjCClassWrapper ()
+{
+
+@private
+ Class wrappedClass;
+ NSMutableArray *subclassesCache;
+}
+
+@end
+
@implementation ObjCClassWrapper
View
10 Example 1/Classes/View/PSHLeafView.h
@@ -11,16 +11,8 @@
#import "PSBaseLeafView.h"
-@interface PSHLeafView : PSBaseLeafView
-{
-
-@private
- // Interface
- UIButton *expandButton_;
- UILabel *titleLabel_;
- UILabel *detailLabel_;
-}
+@interface PSHLeafView : PSBaseLeafView
@property (nonatomic, assign) IBOutlet UIButton *expandButton;
@property (nonatomic, assign) IBOutlet UILabel *titleLabel;
View
16 Example 1/Classes/View/PSHLeafView.m
@@ -10,8 +10,24 @@
#import "PSHLeafView.h"
+@interface PSHLeafView ()
+{
+
+@private
+ // Interface
+ UIButton *expandButton_;
+ UILabel *titleLabel_;
+ UILabel *detailLabel_;
+}
+
+@end
+
+
@implementation PSHLeafView
+
+#pragma mark - Property Accessors
+
@synthesize expandButton = expandButton_;
@synthesize titleLabel = titleLabel_;
@synthesize detailLabel = detailLabel_;
View
6 Example 1/Classes/View/PSHTreeGraphView.h
@@ -11,9 +11,9 @@
#import "PSBaseTreeGraphView.h"
+
@interface PSHTreeGraphView : PSBaseTreeGraphView
-{
- // TODO: Place project specific code, extentions here.
-}
+
+// TODO: Place project specific code, extentions here.
@end
View
14 Example 1/PSHTreeGraph.xcodeproj/project.pbxproj
@@ -358,8 +358,9 @@
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
GCC_WARN_UNUSED_FUNCTION = YES;
INFOPLIST_FILE = "PSHTreeGraph-Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 4.3;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
PRODUCT_NAME = PSHTreeGraph;
+ TARGETED_DEVICE_FAMILY = 2;
};
name = Debug;
};
@@ -374,8 +375,9 @@
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
GCC_WARN_UNUSED_FUNCTION = YES;
INFOPLIST_FILE = "PSHTreeGraph-Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 4.3;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
PRODUCT_NAME = PSHTreeGraph;
+ TARGETED_DEVICE_FAMILY = 2;
VALIDATE_PRODUCT = YES;
};
name = Release;
@@ -403,18 +405,16 @@
C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
"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;
- IPHONEOS_DEPLOYMENT_TARGET = 4.3;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = 2;
USER_HEADER_SEARCH_PATHS = ../PSTreeGraphView/;
@@ -424,18 +424,16 @@
C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
"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;
- IPHONEOS_DEPLOYMENT_TARGET = 4.3;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = 2;
View
2 Example 1/PSHTreeGraph_Prefix.pch
@@ -6,7 +6,7 @@
#import <Availability.h>
#ifndef __IPHONE_4_0
-#warning "This project uses features only available in iPhone SDK 4.0 and later."
+#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif
#ifdef __OBJC__
View
12 Example 1/main.m
@@ -8,9 +8,11 @@
#import <UIKit/UIKit.h>
-int main(int argc, char *argv[]) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- int retVal = UIApplicationMain(argc, argv, nil, nil);
- [pool release];
- return retVal;
+#import "PSHTreeGraphAppDelegate.h"
+
+int main(int argc, char *argv[])
+{
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([PSHTreeGraphAppDelegate class]));
+ }
}
View
1 PSTreeGraphView/PSBaseBranchView.h
@@ -16,7 +16,6 @@
@class PSBaseTreeGraphView;
-
/// Each SubtreeView has a BranchView subview that draws the connecting lines between its root node
/// and its child subtrees.
View
12 PSTreeGraphView/PSBaseLeafView.h
@@ -18,18 +18,6 @@
/// to be a subclass for project specific node views loaded from a nib file.
@interface PSBaseLeafView : UIView
-{
-
-@private
- UIColor *borderColor_;
- CGFloat borderWidth_;
- CGFloat cornerRadius_;
-
- UIColor *fillColor_;
- UIColor *selectionColor_;
-
- BOOL showingSelected_;
-}
#pragma mark - Styling
View
13 PSTreeGraphView/PSBaseLeafView.m
@@ -17,8 +17,19 @@
#import <QuartzCore/QuartzCore.h>
-
@interface PSBaseLeafView ()
+{
+
+@private
+ UIColor *borderColor_;
+ CGFloat borderWidth_;
+ CGFloat cornerRadius_;
+
+ UIColor *fillColor_;
+ UIColor *selectionColor_;
+
+ BOOL showingSelected_;
+}
- (void) updateLayerAppearanceToMatchContainerView;
- (void) configureDetaults;
View
23 PSTreeGraphView/PSBaseSubtreeView.h
@@ -17,7 +17,6 @@
#import "PSTreeGraphModelNode.h"
-@class PSBaseBranchView;
@class PSBaseTreeGraphView;
@@ -27,33 +26,14 @@
@interface PSBaseSubtreeView : UIView
-{
-
-@private
- // Model
- id <PSTreeGraphModelNode> modelNode_; // the model node that nodeView represents
-
- // Views
- 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
-
- // State
- 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
- // and assess its size; NO if we're sure its layout is up to date
-}
/// Initializes a SubtreeView with the associated modelNode. This is SubtreeView's designated initializer.
- initWithModelNode:( id <PSTreeGraphModelNode> )newModelNode;
/// The root of the model subtree that this SubtreeView represents.
-@property (nonatomic, retain) id <PSTreeGraphModelNode> modelNode;
+@property (nonatomic, strong) id <PSTreeGraphModelNode> modelNode;
/// The view that represents the modelNode. Is a subview of SubtreeView, and may itself have descendant views.
@@ -138,6 +118,7 @@
- ( id <PSTreeGraphModelNode> ) modelNodeClosestToX:(CGFloat)x;
+
#pragma mark - Debugging
/// Returns an indented multi-line NSString summary of the displayed tree. Provided as a debugging aid.
View
19 PSTreeGraphView/PSBaseSubtreeView.m
@@ -35,6 +35,25 @@ static CGFloat subtreeBorderWidth(void)
@interface PSBaseSubtreeView ()
+{
+
+@private
+ // Model
+ id <PSTreeGraphModelNode> modelNode_; // the model node that nodeView represents
+
+ // Views
+ 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
+
+ // State
+ 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
+ // and assess its size; NO if we're sure its layout is up to date
+}
- (CGSize) layoutExpandedGraph;
- (CGSize) layoutCollapsedGraph;
View
58 PSTreeGraphView/PSBaseTreeGraphView.h
@@ -13,8 +13,6 @@
#import <UIKit/UIKit.h>
-#import <CoreGraphics/CoreGraphics.h>
-
// A TreeGraph's nodes may be connected by either "direct" or "orthogonal" lines.
@@ -33,70 +31,20 @@ typedef enum {
} PSTreeGraphOrientationStyle;
-@class PSBaseSubtreeView;
+@class PSBaseSubtreeView;
@protocol PSTreeGraphModelNode;
@protocol PSTreeGraphDelegate;
@interface PSBaseTreeGraphView : UIView <UIKeyInput>
-{
-
-@private
- // Model
- id <PSTreeGraphModelNode> modelRoot_;
-
- // Delegate
- id <PSTreeGraphDelegate> delegate_;
-
- // Model Object -> SubtreeView Mapping
- NSMutableDictionary *modelNodeToSubtreeViewMapTable_;
-
- // Selection State
- NSSet *selectedModelNodes_;
-
- // Layout State
- CGSize minimumFrameSize_;
-
- // Animation Support
- BOOL animatesLayout_;
- BOOL layoutAnimationSuppressed_;
-
- // Layout Metrics
- CGFloat contentMargin_;
- CGFloat parentChildSpacing_;
- CGFloat siblingSpacing_;
-
- // Layout Behavior
- BOOL resizesToFillEnclosingScrollView_;
- PSTreeGraphOrientationStyle treeGraphOrientation_;
-
- // Styling
- // UIColor *backgroundColor;
-
- UIColor *connectingLineColor_;
- CGFloat connectingLineWidth_;
- PSTreeGraphConnectingLineStyle connectingLineStyle_;
-
- // A debug feature that outlines the view hiarchy.
- BOOL showsSubtreeFrames_;
-
- // Node View Nib Specification
- NSString *nodeViewNibName_;
-
- // iOS 4 and above ONLY
- UINib *cachedNodeViewNib_;
-
- // Custom input view support
- UIView *inputView_;
-}
#pragma mark - Delegate
-@property (nonatomic, assign) id delegate;
+@property (nonatomic, weak) id delegate;
#pragma mark - Parent Resize Notification
@@ -125,7 +73,7 @@ typedef enum {
/// to traverse the model tree, must conform to the TreeGraphModelNode protocol declared in
/// TreeGraphModelNode.h
-@property (nonatomic, retain) id <PSTreeGraphModelNode> modelRoot;
+@property (nonatomic, strong) id <PSTreeGraphModelNode> modelRoot;
#pragma mark - Root SubtreeView Access
View
76 PSTreeGraphView/PSBaseTreeGraphView.m
@@ -22,7 +22,57 @@
#import <QuartzCore/QuartzCore.h>
-@interface PSBaseTreeGraphView ()
+@interface PSBaseTreeGraphView ()
+{
+
+@private
+ // Model
+ id <PSTreeGraphModelNode> modelRoot_;
+
+ // Delegate
+ id <PSTreeGraphDelegate> delegate_;
+
+ // Model Object -> SubtreeView Mapping
+ NSMutableDictionary *modelNodeToSubtreeViewMapTable_;
+
+ // Selection State
+ NSSet *selectedModelNodes_;
+
+ // Layout State
+ CGSize minimumFrameSize_;
+
+ // Animation Support
+ BOOL animatesLayout_;
+ BOOL layoutAnimationSuppressed_;
+
+ // Layout Metrics
+ CGFloat contentMargin_;
+ CGFloat parentChildSpacing_;
+ CGFloat siblingSpacing_;
+
+ // Layout Behavior
+ BOOL resizesToFillEnclosingScrollView_;
+ PSTreeGraphOrientationStyle treeGraphOrientation_;
+
+ // Styling
+ // UIColor *backgroundColor;
+
+ UIColor *connectingLineColor_;
+ CGFloat connectingLineWidth_;
+ PSTreeGraphConnectingLineStyle connectingLineStyle_;
+
+ // A debug feature that outlines the view hiarchy.
+ BOOL showsSubtreeFrames_;
+
+ // Node View Nib Specification
+ NSString *nodeViewNibName_;
+
+ // iOS 4 and above ONLY
+ UINib *cachedNodeViewNib_;
+
+ // Custom input view support
+ UIView *inputView_;
+}
- (void) configureDetaults;
- (PSBaseSubtreeView *) newGraphForModelNode:(id <PSTreeGraphModelNode> )modelNode;
@@ -452,21 +502,19 @@ - (PSBaseSubtreeView *) newGraphForModelNode:(id <PSTreeGraphModelNode> )modelNo
- (void) buildGraph
{
- // Auto release pool
- NSAutoreleasePool *subPool = [[NSAutoreleasePool alloc] init];
-
- // Traverse the model tree, building a SubtreeView for each model node.
- id <PSTreeGraphModelNode> root = [self modelRoot];
- if (root) {
- PSBaseSubtreeView *rootSubtreeView = [self newGraphForModelNode:root];
- if (rootSubtreeView) {
- [self addSubview:rootSubtreeView];
- [rootSubtreeView release];
+ @autoreleasepool {
+
+ // Traverse the model tree, building a SubtreeView for each model node.
+ id <PSTreeGraphModelNode> root = [self modelRoot];
+ if (root) {
+ PSBaseSubtreeView *rootSubtreeView = [self newGraphForModelNode:root];
+ if (rootSubtreeView) {
+ [self addSubview:rootSubtreeView];
+ [rootSubtreeView release];
+ }
}
- }
- // Drain the pool
- [subPool drain];
+ } // Drain the pool
}

0 comments on commit 02883f8

Please sign in to comment.
Something went wrong with that request. Please try again.