Skip to content

Commit ac2e13e

Browse files
author
Alvise Susmel
committed
fixed alloc, dealloc. Now supporting arc enable/disable
1 parent f661694 commit ac2e13e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+4235
-29
lines changed

ARCMacros.h

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// ARCMacros.h
3+
//
4+
// Created by John Blanco on 1/28/2011.
5+
// Rapture In Venice releases all rights to this code. Feel free use and/or copy it openly and freely!
6+
//
7+
8+
#define FP_DEBUG
9+
10+
#if !defined(__clang__) || __clang_major__ < 3
11+
#ifndef __bridge
12+
#define __bridge
13+
#endif
14+
15+
#ifndef __bridge_retain
16+
#define __bridge_retain
17+
#endif
18+
19+
#ifndef __bridge_retained
20+
#define __bridge_retained
21+
#endif
22+
23+
#ifndef __autoreleasing
24+
#define __autoreleasing
25+
#endif
26+
27+
#ifndef __strong
28+
#define __strong
29+
#endif
30+
31+
#ifndef __unsafe_unretained
32+
#define __unsafe_unretained
33+
#endif
34+
35+
#ifndef __weak
36+
#define __weak
37+
#endif
38+
#endif
39+
40+
#if __has_feature(objc_arc)
41+
#define SAFE_ARC_PROP_RETAIN strong
42+
#define SAFE_ARC_RETAIN(x) (x)
43+
#define SAFE_ARC_RELEASE(x)
44+
#define SAFE_ARC_AUTORELEASE(x) (x)
45+
#define SAFE_ARC_BLOCK_COPY(x) (x)
46+
#define SAFE_ARC_BLOCK_RELEASE(x)
47+
#define SAFE_ARC_SUPER_DEALLOC()
48+
#define SAFE_ARC_AUTORELEASE_POOL_START() @autoreleasepool {
49+
#define SAFE_ARC_AUTORELEASE_POOL_END() }
50+
#else
51+
#define SAFE_ARC_PROP_RETAIN retain
52+
#define SAFE_ARC_RETAIN(x) ([(x) retain])
53+
#define SAFE_ARC_RELEASE(x) ([(x) release])
54+
#define SAFE_ARC_AUTORELEASE(x) ([(x) autorelease])
55+
#define SAFE_ARC_BLOCK_COPY(x) (Block_copy(x))
56+
#define SAFE_ARC_BLOCK_RELEASE(x) (Block_release(x))
57+
#define SAFE_ARC_SUPER_DEALLOC() ([super dealloc])
58+
#define SAFE_ARC_AUTORELEASE_POOL_START() NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
59+
#define SAFE_ARC_AUTORELEASE_POOL_END() [pool release];
60+
#endif
61+
62+

FPPopoverController.h

+11-13
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
#import <UIKit/UIKit.h>
1010
#import <QuartzCore/QuartzCore.h>
1111

12+
#import "ARCMacros.h"
13+
1214
#import "FPPopoverView.h"
1315
#import "FPTouchView.h"
1416

17+
1518
@class FPPopoverController;
1619
@protocol FPPopoverControllerDelegate <NSObject>
1720

@@ -22,19 +25,14 @@
2225
@end
2326

2427
@interface FPPopoverController : UIViewController
25-
{
26-
FPTouchView *_touchView;
27-
FPPopoverView *_contentView;
28-
UIViewController *_viewController;
29-
UIWindow *_window;
30-
UIView *_parentView;
31-
UIView *_fromView;
32-
UIDeviceOrientation _deviceOrientation;
33-
34-
BOOL _shadowsHidden;
35-
CGColorRef _shadowColor;
36-
}
37-
@property(nonatomic,weak) id<FPPopoverControllerDelegate> delegate;
28+
29+
//ARC-enable and disable support
30+
#if __has_feature(objc_arc)
31+
@property(nonatomic,weak) id<FPPopoverControllerDelegate> delegate;
32+
#else
33+
@property(nonatomic,assign) id<FPPopoverControllerDelegate> delegate;
34+
#endif
35+
3836
/** @brief FPPopoverArrowDirectionAny, FPPopoverArrowDirectionVertical or FPPopoverArrowDirectionHorizontal for automatic arrow direction.
3937
**/
4038

FPPopoverController.m

+31-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@
99

1010
#import "FPPopoverController.h"
1111

12+
//ivars
13+
@interface FPPopoverController()
14+
{
15+
FPTouchView *_touchView;
16+
FPPopoverView *_contentView;
17+
UIViewController *_viewController;
18+
UIWindow *_window;
19+
UIView *_parentView;
20+
UIView *_fromView;
21+
UIDeviceOrientation _deviceOrientation;
22+
23+
BOOL _shadowsHidden;
24+
CGColorRef _shadowColor;
25+
}
26+
@end
27+
28+
29+
//private methods
1230
@interface FPPopoverController(Private)
1331
-(CGPoint)originFromView:(UIView*)fromView;
1432

@@ -66,6 +84,17 @@ -(void)dealloc
6684
{
6785
[self removeObservers];
6886
if(_shadowColor) CGColorRelease(_shadowColor);
87+
88+
#ifdef FP_DEBUG
89+
NSLog(@"FPPopoverController dealloc");
90+
#endif
91+
92+
SAFE_ARC_RELEASE(_contentView);
93+
SAFE_ARC_RELEASE(_touchView);
94+
self.delegate = nil;
95+
_viewController = nil;
96+
97+
SAFE_ARC_SUPER_DEALLOC();
6998
}
7099

71100
-(id)initWithViewController:(UIViewController*)viewController {
@@ -89,7 +118,8 @@ -(id)initWithViewController:(UIViewController*)viewController
89118
_touchView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
90119
_touchView.clipsToBounds = NO;
91120
[self.view addSubview:_touchView];
92-
121+
122+
93123
__block typeof (self) bself = self;
94124
[_touchView setTouchedOutsideBlock:^{
95125
[bself dismissPopoverAnimated:YES];

0 commit comments

Comments
 (0)