Skip to content

Commit 514a438

Browse files
author
Michael Gray
committedMar 12, 2013
Added support to compile with weak delegate pointers with backward compability for older compilers and SDK environments
1 parent 13c0f12 commit 514a438

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed
 

‎ViewDeck/IIViewDeckController.h

+25-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,29 @@
2525

2626
#import <UIKit/UIKit.h>
2727

28+
// thanks to http://stackoverflow.com/a/8594878/742176
29+
30+
#if TARGET_OS_IPHONE && defined(__IPHONE_5_0) && (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0) && __clang__ && (__clang_major__ >= 3)
31+
#define II_SDK_SUPPORTS_WEAK 1
32+
#elif TARGET_OS_MAC && defined(__MAC_10_7) && (MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_7) && __clang__ && (__clang_major__ >= 3)
33+
#define II_SDK_SUPPORTS_WEAK 1
34+
#else
35+
#define II_SDK_SUPPORTS_WEAK 0
36+
#endif
37+
38+
#if II_SDK_SUPPORTS_WEAK
39+
#define __ii_weak __weak
40+
#define ii_weak_property weak
41+
#else
42+
#if __clang__ && (__clang_major__ >= 3)
43+
#define __ii_weak __unsafe_unretained
44+
#else
45+
#define __ii_weak
46+
#endif
47+
#define ii_weak_property assign
48+
#endif
49+
50+
2851
@protocol IIViewDeckControllerDelegate;
2952

3053
enum {
@@ -105,7 +128,7 @@ extern IIViewDeckOffsetOrientation IIViewDeckOffsetOrientationFromIIViewDeckSide
105128
typedef void (^IIViewDeckControllerBlock) (IIViewDeckController *controller, BOOL success);
106129
typedef void (^IIViewDeckControllerBounceBlock) (IIViewDeckController *controller);
107130

108-
@property (nonatomic, assign) id<IIViewDeckControllerDelegate> delegate;
131+
@property (nonatomic, ii_weak_property) __ii_weak id<IIViewDeckControllerDelegate> delegate;
109132
@property (nonatomic, assign) IIViewDeckDelegateMode delegateMode;
110133

111134
@property (nonatomic, readonly, retain) NSArray* controllers;
@@ -117,7 +140,7 @@ typedef void (^IIViewDeckControllerBounceBlock) (IIViewDeckController *controlle
117140
@property (nonatomic, readonly, assign) UIViewController* slidingController;
118141

119142
@property (nonatomic, retain) UIView* panningView;
120-
@property (nonatomic, assign) id<UIGestureRecognizerDelegate> panningGestureDelegate;
143+
@property (nonatomic, ii_weak_property) __ii_weak id<UIGestureRecognizerDelegate> panningGestureDelegate;
121144
@property (nonatomic, assign, getter=isEnabled) BOOL enabled;
122145
@property (nonatomic, assign, getter=isElastic) BOOL elastic;
123146

0 commit comments

Comments
 (0)
Please sign in to comment.