Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Enabled ARC #1

Open
wants to merge 2 commits into from

1 participant

@ened

Perhaps this should move into another branch to support older XCode versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 13, 2012
  1. @ened

    Enable ARC

    ened authored
  2. @ened

    Added compatibility for tab bars on the bottom & disable panning if l…

    ened authored
    …eft/right view controllers are not available.
This page is out of date. Refresh to see the latest.
View
13 ExampleProject/AppDelegate.m
@@ -18,16 +18,10 @@ @implementation AppDelegate
@synthesize window = _window;
@synthesize slideViewController = _viewController;
-- (void)dealloc
-{
- [_window release];
- [_viewController release];
- [super dealloc];
-}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
- self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
+ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
/*if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
@@ -38,7 +32,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
MainViewController * mainVc = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
- self.slideViewController = [[[MKDSlideViewController alloc] initWithRootViewController:mainVc] autorelease];
+ self.slideViewController = [[MKDSlideViewController alloc] initWithRootViewController:mainVc];
// Left & Right
LeftViewController * vcLeft = [[LeftViewController alloc] initWithNibName:@"LeftViewController" bundle:nil];
@@ -46,9 +40,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
RightViewController * vcRight = [[RightViewController alloc] initWithNibName:@"RightViewController" bundle:nil];
[self.slideViewController setLeftViewController:vcLeft rightViewController:vcRight];
- [vcLeft release];
- [vcRight release];
- [mainVc release];
self.window.rootViewController = self.slideViewController;
[self.window makeKeyAndVisible];
View
2  ExampleProject/LeftViewController.h
@@ -10,7 +10,7 @@
@interface LeftViewController : UIViewController
-@property (nonatomic, assign) UIViewController * mainViewController;
+@property (nonatomic, weak) UIViewController * mainViewController;
- (IBAction)changeText:(id)sender;
- (IBAction)navigateToMainViewController:(id)sender;
View
2  ExampleProject/MainViewController.h
@@ -10,7 +10,7 @@
@interface MainViewController : UIViewController
-@property (nonatomic, retain) IBOutlet UITextView * textView;
+@property (nonatomic, strong) IBOutlet UITextView * textView;
- (void)setDetailText:(NSString *)detailText;
View
2  ExampleProject/MainViewController.m
@@ -41,14 +41,12 @@ - (void)viewDidLoad
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap)];
[self.view addGestureRecognizer:tap];
- [tap release];
}
- (void)tap
{
SecondLevelViewController * sl = [[SecondLevelViewController alloc] initWithNibName:@"SecondLevelViewController" bundle:nil];
[self.navigationController pushViewController:sl animated:YES];
- [sl release];
}
- (void)viewDidUnload
View
8 MKDSlideViewController.h
@@ -14,11 +14,11 @@
@interface MKDSlideViewController : UIViewController
-@property (nonatomic, retain) UIViewController * leftViewController;
-@property (nonatomic, retain) UIViewController * rightViewController;
-@property (nonatomic, retain) UIViewController * rootViewController;
+@property (nonatomic, strong) UIViewController * leftViewController;
+@property (nonatomic, strong) UIViewController * rightViewController;
+@property (nonatomic, strong) UIViewController * rootViewController;
-@property (nonatomic, retain) UIBarButtonItem * menuBarButtonItem;
+@property (nonatomic, strong) UIBarButtonItem * menuBarButtonItem;
- (id)initWithRootViewController:(UIViewController *)rootViewController;
- (void)setLeftViewController:(UIViewController *)leftViewController rightViewController:(UIViewController *)rightViewController;
View
43 MKDSlideViewController.m
@@ -10,10 +10,10 @@
@interface MKDSlideViewController ()
-@property (nonatomic, retain) UIViewController * mainViewController;
-@property (nonatomic, retain) UIView * mainContainerView;
-@property (nonatomic, retain) UIView * mainTapView;
-@property (nonatomic, retain) UIPanGestureRecognizer * panGesture;
+@property (nonatomic, strong) UIViewController * mainViewController;
+@property (nonatomic, strong) UIView * mainContainerView;
+@property (nonatomic, strong) UIView * mainTapView;
+@property (nonatomic, strong) UIPanGestureRecognizer * panGesture;
@property (nonatomic) CGPoint previousLocation;
- (void)setupPanGestureForView:(UIView *)view;
@@ -55,7 +55,7 @@ - (void)didReceiveMemoryWarning
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
- UIView * containerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 460.0)];
+ UIView * containerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 480.0)];
containerView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
containerView.backgroundColor = [UIColor viewFlipsideBackgroundColor];
@@ -67,7 +67,6 @@ - (void)loadView
[self setupPanGestureForView:navController.navigationBar];
self.mainViewController = navController;
- [navController release];
[self addChildViewController:self.mainViewController];
self.mainViewController.view.clipsToBounds = YES;
@@ -95,7 +94,6 @@ - (void)loadView
}
self.view = containerView;
- [containerView release];
}
/*
@@ -119,20 +117,6 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-- (void)dealloc
-{
- [_leftViewController release];
- [_rightViewController release];
- [_mainViewController release];
- [_rootViewController release];
- [_mainContainerView release];
- [_mainTapView release];
-
- [_panGesture release];
- [_menuBarButtonItem release];
-
- [super dealloc];
-}
#pragma mark - Sub View Controllers
@@ -166,7 +150,6 @@ - (void)setupPanGestureForView:(UIView *)view
pan.maximumNumberOfTouches = 1;
self.panGesture = pan;
[view addGestureRecognizer:pan];
- [pan release];
}
- (void)panGesture:(UIPanGestureRecognizer *)gesture
@@ -185,6 +168,13 @@ - (void)panGesture:(UIPanGestureRecognizer *)gesture
// Calculate position offset
CGPoint locationInView = [gesture translationInView:self.view];
+
+ if (!self.rightViewController && locationInView.x < 0) {
+ return;
+ }
+ if (!self.leftViewController && locationInView.x > 0) {
+ return;
+ }
CGFloat deltaX = locationInView.x - self.previousLocation.x;
// Update view frame
@@ -233,7 +223,6 @@ - (void)addTapViewOverlay
tap.numberOfTouchesRequired = 1;
[self.mainTapView addGestureRecognizer:tap];
- [tap release];
// Pan Gesture
[self setupPanGestureForView:self.mainTapView];
@@ -254,6 +243,10 @@ - (void)removeTapViewOverlay
- (IBAction)showLeftViewController:(id)sender
{
+ if(! self.leftViewController) {
+ return;
+ }
+
[self.view sendSubviewToBack:self.rightViewController.view];
[UIView animateWithDuration:kSlideSpeed animations:^{
@@ -267,6 +260,10 @@ - (IBAction)showLeftViewController:(id)sender
- (IBAction)showRightViewController:(id)sender
{
+ if(! self.rightViewController) {
+ return;
+ }
+
[self.view sendSubviewToBack:self.leftViewController.view]; // FIXME: Correct timing, when sending to back
[UIView animateWithDuration:kSlideSpeed animations:^{
View
2  MKDSlideViewController.xcodeproj/project.pbxproj
@@ -286,6 +286,7 @@
DA953C82148AD3700075A1E2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_ARC = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ExampleProject/MKDSlideViewController-Prefix.pch";
INFOPLIST_FILE = "ExampleProject/MKDSlideViewController-Info.plist";
@@ -297,6 +298,7 @@
DA953C83148AD3700075A1E2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_ARC = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ExampleProject/MKDSlideViewController-Prefix.pch";
INFOPLIST_FILE = "ExampleProject/MKDSlideViewController-Info.plist";
Something went wrong with that request. Please try again.