diff --git a/EGOCache b/EGOCache index 8b7c7ec..018a217 160000 --- a/EGOCache +++ b/EGOCache @@ -1 +1 @@ -Subproject commit 8b7c7ecfc8fad396b6547ad3fef085713644f794 +Subproject commit 018a2171b15ba71b3cab028b267b649c56cc0641 diff --git a/EGOImageButton/EGOImageButton.h b/EGOImageButton/EGOImageButton.h index 0367812..b7be544 100644 --- a/EGOImageButton/EGOImageButton.h +++ b/EGOImageButton/EGOImageButton.h @@ -32,7 +32,11 @@ @private NSURL* imageURL; UIImage* placeholderImage; +#if EGO_NO_ARC id delegate; +#else + __unsafe_unretained id delegate; +#endif } - (id)initWithPlaceholderImage:(UIImage*)anImage; // delegate:nil @@ -40,9 +44,15 @@ - (void)cancelImageLoad; +#if EGO_NO_ARC @property(nonatomic,retain) NSURL* imageURL; @property(nonatomic,retain) UIImage* placeholderImage; @property(nonatomic,assign) id delegate; +#else +@property(nonatomic,strong) NSURL* imageURL; +@property(nonatomic,strong) UIImage* placeholderImage; +@property(nonatomic,unsafe_unretained) id delegate; +#endif @end @protocol EGOImageButtonDelegate diff --git a/EGOImageButton/EGOImageButton.m b/EGOImageButton/EGOImageButton.m index 8afe756..2794fbf 100644 --- a/EGOImageButton/EGOImageButton.m +++ b/EGOImageButton/EGOImageButton.m @@ -47,7 +47,9 @@ - (id)initWithPlaceholderImage:(UIImage*)anImage delegate:(id _delegate; +#else + __unsafe_unretained id _delegate; +#endif } - (id)initWithImageURL:(NSURL*)aURL delegate:(id)delegate; @@ -47,8 +51,13 @@ @property(nonatomic,readonly) NSData* responseData; @property(nonatomic,readonly,getter=imageURL) NSURL* imageURL; +#if EGO_NO_ARC @property(nonatomic,retain) NSURLResponse* response; @property(nonatomic,assign) id delegate; +#else +@property(nonatomic,strong) NSURLResponse* response; +@property(nonatomic,unsafe_unretained) id delegate; +#endif @property(nonatomic,assign) NSTimeInterval timeoutInterval; // Default is 30 seconds diff --git a/EGOImageLoader/EGOImageLoadConnection.m b/EGOImageLoader/EGOImageLoadConnection.m index 435225a..a6e29e2 100644 --- a/EGOImageLoader/EGOImageLoadConnection.m +++ b/EGOImageLoader/EGOImageLoadConnection.m @@ -36,7 +36,11 @@ @implementation EGOImageLoadConnection - (id)initWithImageURL:(NSURL*)aURL delegate:(id)delegate { if((self = [super init])) { +#if EGO_NO_ARC _imageURL = [aURL retain]; +#else + _imageURL = aURL; +#endif self.delegate = delegate; _responseData = [[NSMutableData alloc] init]; self.timeoutInterval = 30; @@ -55,7 +59,9 @@ - (void)start { timeoutInterval:self.timeoutInterval]; [request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"]; _connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES]; +#if EGO_NO_ARC [request release]; +#endif } - (void)cancel { @@ -98,13 +104,18 @@ - (void)dealloc { self.delegate = nil; #if __EGOIL_USE_BLOCKS - [handlers release], handlers = nil; +#if EGO_NO_ARC + [handlers release]; +#endif + handlers = nil; #endif +#if EGO_NO_ARC [_connection release]; [_imageURL release]; [_responseData release]; [super dealloc]; +#endif } @end diff --git a/EGOImageLoader/EGOImageLoader.h b/EGOImageLoader/EGOImageLoader.h index 7997e9d..ad3f2a4 100644 --- a/EGOImageLoader/EGOImageLoader.h +++ b/EGOImageLoader/EGOImageLoader.h @@ -34,6 +34,12 @@ #define __EGOIL_USE_NOTIF 1 #endif +#ifdef __has_feature +#define EGO_NO_ARC !__has_feature(objc_arc) +#else +#define EGO_NO_ARC 1 +#endif + @protocol EGOImageLoaderObserver; @interface EGOImageLoader : NSObject/**/ { @private @@ -69,7 +75,11 @@ - (void)clearCacheForURL:(NSURL*)aURL; - (void)clearCacheForURL:(NSURL*)aURL style:(NSString*)style; +#if EGO_NO_ARC @property(nonatomic,retain) NSDictionary* currentConnections; +#else +@property(nonatomic,strong) NSDictionary* currentConnections; +#endif @end @protocol EGOImageLoaderObserver diff --git a/EGOImageLoader/EGOImageLoader.m b/EGOImageLoader/EGOImageLoader.m index 32a619a..13fe729 100644 --- a/EGOImageLoader/EGOImageLoader.m +++ b/EGOImageLoader/EGOImageLoader.m @@ -86,9 +86,18 @@ - (id)init { } - (EGOImageLoadConnection*)loadingConnectionForURL:(NSURL*)aURL { +#if EGO_NO_ARC EGOImageLoadConnection* connection = [[self.currentConnections objectForKey:aURL] retain]; +#else + EGOImageLoadConnection* connection = [self.currentConnections objectForKey:aURL]; +#endif if(!connection) return nil; - else return [connection autorelease]; + else { +#if EGO_NO_ARC + [connection autorelease]; +#endif + return connection; + } } - (void)cleanUpConnection:(EGOImageLoadConnection*)connection { @@ -98,7 +107,10 @@ - (void)cleanUpConnection:(EGOImageLoadConnection*)connection { [connectionsLock lock]; [currentConnections removeObjectForKey:connection.imageURL]; - self.currentConnections = [[currentConnections copy] autorelease]; + self.currentConnections = [currentConnections copy]; +#if EGO_NO_ARC + [self.currentConnections autorelease]; +#endif [connectionsLock unlock]; } @@ -131,10 +143,15 @@ - (EGOImageLoadConnection*)loadImageForURL:(NSURL*)aURL { [connectionsLock lock]; [currentConnections setObject:connection forKey:aURL]; - self.currentConnections = [[currentConnections copy] autorelease]; + self.currentConnections = [currentConnections copy]; +#if EGO_NO_ARC + [self.currentConnections autorelease]; +#endif [connectionsLock unlock]; [connection performSelector:@selector(start) withObject:nil afterDelay:0.01]; +#if EGO_NO_ARC [connection release]; +#endif return connection; } @@ -212,14 +229,20 @@ - (void)loadImageForURL:(NSURL*)aURL style:(NSString*)style styler:(UIImage* (^) if(styler) { UIImage* (^stylerCopy)(UIImage* image) = [styler copy]; [handler setObject:stylerCopy forKey:kStylerKey]; +#if EGO_NO_ARC [stylerCopy release]; +#endif } +#if EGO_NO_ARC [handler release]; +#endif } [[handler objectForKey:kCompletionsKey] addObject:completionCopy]; +#if EGO_NO_ARC [completionCopy release]; +#endif } } #endif @@ -252,7 +275,10 @@ - (void)imageLoadConnectionDidFinishLoading:(EGOImageLoadConnection *)connection [[EGOCache currentCache] setData:connection.responseData forKey:keyForURL(connection.imageURL,nil) withTimeoutInterval:604800]; [currentConnections removeObjectForKey:connection.imageURL]; - self.currentConnections = [[currentConnections copy] autorelease]; + self.currentConnections = [currentConnections copy]; +#if EGO_NO_ARC + [self.currentConnections autorelease]; +#endif #if __EGOIL_USE_NOTIF NSNotification* notification = [NSNotification notificationWithName:kImageNotificationLoaded(connection.imageURL) @@ -274,7 +300,10 @@ - (void)imageLoadConnectionDidFinishLoading:(EGOImageLoadConnection *)connection - (void)imageLoadConnection:(EGOImageLoadConnection *)connection didFailWithError:(NSError *)error { [currentConnections removeObjectForKey:connection.imageURL]; - self.currentConnections = [[currentConnections copy] autorelease]; + self.currentConnections = [currentConnections copy]; +#if EGO_NO_ARC + [self.currentConnections autorelease]; +#endif #if __EGOIL_USE_NOTIF NSNotification* notification = [NSNotification notificationWithName:kImageNotificationLoadFailed(connection.imageURL) @@ -329,9 +358,15 @@ - (void)dealloc { #endif self.currentConnections = nil; - [currentConnections release], currentConnections = nil; - [connectionsLock release], connectionsLock = nil; +#if EGO_NO_ARC + [currentConnections release]; + [connectionsLock release]; +#endif + currentConnections = nil; + connectionsLock = nil; +#if EGO_NO_ARC [super dealloc]; +#endif } @end \ No newline at end of file diff --git a/EGOImageView/EGOImageView.h b/EGOImageView/EGOImageView.h index 5f331aa..27ca7c9 100644 --- a/EGOImageView/EGOImageView.h +++ b/EGOImageView/EGOImageView.h @@ -32,7 +32,11 @@ @private NSURL* imageURL; UIImage* placeholderImage; +#if EGO_NO_ARC id delegate; +#else + __unsafe_unretained id delegate; +#endif } - (id)initWithPlaceholderImage:(UIImage*)anImage; // delegate:nil @@ -42,7 +46,11 @@ @property(nonatomic,retain) NSURL* imageURL; @property(nonatomic,retain) UIImage* placeholderImage; +#if EGO_NO_ARC @property(nonatomic,assign) id delegate; +#else +@property(nonatomic,unsafe_unretained) id delegate; +#endif @end @protocol EGOImageViewDelegate diff --git a/EGOImageView/EGOImageView.m b/EGOImageView/EGOImageView.m index adae4b5..d605cf4 100644 --- a/EGOImageView/EGOImageView.m +++ b/EGOImageView/EGOImageView.m @@ -46,7 +46,9 @@ - (id)initWithPlaceholderImage:(UIImage*)anImage delegate:(id