Skip to content

Commit

Permalink
Added compatibility with arc and non-arc project
Browse files Browse the repository at this point in the history
  • Loading branch information
brunow committed Feb 12, 2012
1 parent a0e777c commit f484028
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
26 changes: 20 additions & 6 deletions ITWLoadingPanel/ITWLoadingPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,30 @@

#import <UIKit/UIKit.h>

#ifndef ILP_USE_ARC
#define ILP_USE_ARC __has_feature(objc_arc)
#endif

#if ILP_USE_ARC
#define ILP_RETAIN(xx) xx
#define ILP_RELEASE(xx)
#define ILP_AUTORELEASE(xx) xx
#else
#define ILP_RETAIN(xx) [xx retain];
#define ILP_RELEASE(xx) [xx release];
#define ILP_AUTORELEASE(xx) [xx autorelease];
#endif

typedef void(^ITWLoadingPanelBasicBlock)(void);

@interface ITWLoadingPanel : UIView

@property (nonatomic, retain) IBOutlet UIButton *cancelBtn;
@property (nonatomic, retain) IBOutlet UIProgressView *progressView;
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *activityView;
@property (nonatomic, retain) IBOutlet UIImageView *successImageView;
@property (nonatomic, retain) IBOutlet UILabel *cancelLabel;
@property (nonatomic, retain) IBOutlet UILabel *titleLabel;
@property (nonatomic, strong) IBOutlet UIButton *cancelBtn;
@property (nonatomic, strong) IBOutlet UIProgressView *progressView;
@property (nonatomic, strong) IBOutlet UIActivityIndicatorView *activityView;
@property (nonatomic, strong) IBOutlet UIImageView *successImageView;
@property (nonatomic, strong) IBOutlet UILabel *cancelLabel;
@property (nonatomic, strong) IBOutlet UILabel *titleLabel;
@property (nonatomic, readonly) CFTimeInterval animationDuration;
@property (nonatomic, copy) ITWLoadingPanelBasicBlock onDisappearBlock;
@property (nonatomic, copy) ITWLoadingPanelBasicBlock onCancelBlock;
Expand Down
8 changes: 6 additions & 2 deletions ITWLoadingPanel/ITWLoadingPanel.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,18 @@ - (void)dealloc {
self.onCancelBlock = nil;
self.onDisappearBlock = nil;

#ifdef ILP_USE_ARC
// Do nothing
#else
[super dealloc];
#endif
}


////////////////////////////////////////////////////////////////////////////////////////////////////
+ (id)sharedInstance {
if (_sharedObject == nil) {
_sharedObject = [[self panel] retain];
_sharedObject = ILP_RETAIN([self panel]);
}

return _sharedObject;
Expand Down Expand Up @@ -238,7 +242,7 @@ - (void)hidePanel {
////////////////////////////////////////////////////////////////////////////////////////////////////
- (void)removePanelFromView {
[self removeFromSuperview];
[_sharedObject release];
ILP_RELEASE(_sharedObject);
_sharedObject = nil;
}

Expand Down

0 comments on commit f484028

Please sign in to comment.