@@ -19,19 +19,26 @@ - (void)handleGraceTimer:(NSTimer *)theTimer;
1919- (void )handleMinShowTimer : (NSTimer *)theTimer ;
2020- (void )setTransformForCurrentOrientation : (BOOL )animated ;
2121- (void )cleanUp ;
22- - (void )deviceOrientationDidChange : (NSNotification *)notification ;
2322- (void )launchExecution ;
2423- (void )deviceOrientationDidChange : (NSNotification *)notification ;
2524- (void )hideDelayed : (NSNumber *)animated ;
2625- (void )launchExecution ;
2726- (void )cleanUp ;
2827
28+ #if __has_feature(objc_arc)
29+ @property (strong ) UIView *indicator;
30+ @property (strong ) NSTimer *graceTimer;
31+ @property (strong ) NSTimer *minShowTimer;
32+ @property (strong ) NSDate *showStarted;
33+ #else
2934@property (retain ) UIView *indicator;
30- @property (assign ) float width;
31- @property (assign ) float height;
3235@property (retain ) NSTimer *graceTimer;
3336@property (retain ) NSTimer *minShowTimer;
3437@property (retain ) NSDate *showStarted;
38+ #endif
39+
40+ @property (assign ) float width;
41+ @property (assign ) float height;
3542
3643@end
3744
@@ -149,14 +156,18 @@ - (float)progress {
149156
150157- (void )updateLabelText : (NSString *)newText {
151158 if (labelText != newText) {
159+ #if !__has_feature(objc_arc)
152160 [labelText release ];
161+ #endif
153162 labelText = [newText copy ];
154163 }
155164}
156165
157166- (void )updateDetailsLabelText : (NSString *)newText {
158167 if (detailsLabelText != newText) {
168+ #if !__has_feature(objc_arc)
159169 [detailsLabelText release ];
170+ #endif
160171 detailsLabelText = [newText copy ];
161172 }
162173}
@@ -171,13 +182,22 @@ - (void)updateIndicators {
171182 }
172183
173184 if (mode == MBProgressHUDModeDeterminate) {
185+ #if __has_feature(objc_arc)
186+ self.indicator = [[MBRoundProgressView alloc ] init ];
187+ #else
174188 self.indicator = [[[MBRoundProgressView alloc ] init ] autorelease ];
175- }
189+ #endif
190+ }
176191 else if (mode == MBProgressHUDModeCustomView && self.customView != nil ){
177192 self.indicator = self.customView ;
178193 } else {
194+ #if __has_feature(objc_arc)
195+ self.indicator = [[UIActivityIndicatorView alloc ]
196+ initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge];
197+ #else
179198 self.indicator = [[[UIActivityIndicatorView alloc ]
180199 initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge] autorelease ];
200+ #endif
181201 [(UIActivityIndicatorView *)indicator startAnimating ];
182202 }
183203
@@ -200,7 +220,11 @@ + (MBProgressHUD *)showHUDAddedTo:(UIView *)view animated:(BOOL)animated {
200220 MBProgressHUD *hud = [[MBProgressHUD alloc ] initWithView: view];
201221 [view addSubview: hud];
202222 [hud show: animated];
223+ #if __has_feature(objc_arc)
224+ return hud;
225+ #else
203226 return [hud autorelease ];
227+ #endif
204228}
205229
206230+ (BOOL )hideHUDForView : (UIView *)view animated : (BOOL )animated {
@@ -245,6 +269,15 @@ - (id)initWithView:(UIView *)view {
245269 return me;
246270}
247271
272+ - (void )removeFromSuperview {
273+ [[NSNotificationCenter defaultCenter ] removeObserver: self
274+ name: UIDeviceOrientationDidChangeNotification
275+ object: nil ];
276+
277+ [super removeFromSuperview ];
278+ }
279+
280+
248281- (id )initWithFrame : (CGRect)frame {
249282 self = [super initWithFrame: frame];
250283 if (self) {
@@ -287,9 +320,8 @@ - (id)initWithFrame:(CGRect)frame {
287320 return self;
288321}
289322
323+ #if !__has_feature(objc_arc)
290324- (void )dealloc {
291- [[NSNotificationCenter defaultCenter ] removeObserver: self ];
292-
293325 [indicator release ];
294326 [label release ];
295327 [detailsLabel release ];
@@ -301,6 +333,7 @@ - (void)dealloc {
301333 [customView release ];
302334 [super dealloc ];
303335}
336+ #endif
304337
305338#pragma mark -
306339#pragma mark Layout
@@ -484,9 +517,14 @@ - (void)handleMinShowTimer:(NSTimer *)theTimer {
484517- (void )showWhileExecuting : (SEL )method onTarget : (id )target withObject : (id )object animated : (BOOL )animated {
485518
486519 methodForExecution = method;
520+ #if __has_feature(objc_arc)
521+ targetForExecution = target;
522+ objectForExecution = object;
523+ #else
487524 targetForExecution = [target retain ];
488525 objectForExecution = [object retain ];
489-
526+ #endif
527+
490528 // Launch execution in new thread
491529 taskInProgress = YES ;
492530 [NSThread detachNewThreadSelector: @selector (launchExecution ) toTarget: self withObject: nil ];
@@ -496,16 +534,19 @@ - (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object
496534}
497535
498536- (void )launchExecution {
537+ #if !__has_feature(objc_arc)
499538 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc ] init ];
500-
539+ # endif
501540 // Start executing the requested task
502541 [targetForExecution performSelector: methodForExecution withObject: objectForExecution];
503542
504543 // Task completed, update view in main thread (note: view operations should
505544 // be done only in the main thread)
506545 [self performSelectorOnMainThread: @selector (cleanUp ) withObject: nil waitUntilDone: NO ];
507546
547+ #if !__has_feature(objc_arc)
508548 [pool release ];
549+ #endif
509550}
510551
511552- (void )animationFinished : (NSString *)animationID finished : (BOOL )finished context : (void *)context {
@@ -536,8 +577,10 @@ - (void)cleanUp {
536577
537578 self.indicator = nil ;
538579
580+ #if !__has_feature(objc_arc)
539581 [targetForExecution release ];
540582 [objectForExecution release ];
583+ #endif
541584
542585 [self hide: useAnimation];
543586}
0 commit comments