Skip to content

Commit

Permalink
upgraded to AFNetworking 2.2.3, updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yurrriq committed Apr 24, 2014
1 parent c9aacd2 commit d217528
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 39 deletions.
4 changes: 0 additions & 4 deletions EWCacheManager.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
075FAE881862546C00248796 /* EWCacheManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 075FAE871862546C00248796 /* EWCacheManager.m */; };
075FAE8F1862546C00248796 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 075FAE8E1862546C00248796 /* XCTest.framework */; };
075FAE901862546C00248796 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 075FAE801862546C00248796 /* Foundation.framework */; };
075FAE921862546C00248796 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 075FAE911862546C00248796 /* UIKit.framework */; };
075FAE951862546C00248796 /* libEWCacheManager.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 075FAE7D1862546C00248796 /* libEWCacheManager.a */; };
075FAE9B1862546C00248796 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 075FAE991862546C00248796 /* InfoPlist.strings */; };
075FAE9D1862546C00248796 /* EWCacheManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 075FAE9C1862546C00248796 /* EWCacheManagerTests.m */; };
Expand Down Expand Up @@ -65,7 +64,6 @@
075FAE871862546C00248796 /* EWCacheManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EWCacheManager.m; sourceTree = "<group>"; };
075FAE8D1862546C00248796 /* EWCacheManagerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = EWCacheManagerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
075FAE8E1862546C00248796 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
075FAE911862546C00248796 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
075FAE981862546C00248796 /* EWCacheManagerTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "EWCacheManagerTests-Info.plist"; sourceTree = "<group>"; };
075FAE9A1862546C00248796 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
075FAE9C1862546C00248796 /* EWCacheManagerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EWCacheManagerTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -93,7 +91,6 @@
files = (
075FAE951862546C00248796 /* libEWCacheManager.a in Frameworks */,
075FAE8F1862546C00248796 /* XCTest.framework in Frameworks */,
075FAE921862546C00248796 /* UIKit.framework in Frameworks */,
075FAE901862546C00248796 /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -129,7 +126,6 @@
07B6CC241862552300EB1FA7 /* SystemConfiguration.framework */,
075FAE801862546C00248796 /* Foundation.framework */,
075FAE8E1862546C00248796 /* XCTest.framework */,
075FAE911862546C00248796 /* UIKit.framework */,
3630EA26D21847648CD89AFD /* libPods.a */,
);
name = Frameworks;
Expand Down
Binary file not shown.
28 changes: 17 additions & 11 deletions EWCacheManager/EWCacheManager.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
File: EWCacheManager.h
Version: 1.1
Version: 1.2
Created: 2013-12-06
Updated: 2014-03-14
Updated: 2014-04-24
Author: Eric Bailey <[email protected]>
Electric Wizardry, LLC <http://electric-wizardry.com>
Expand Down Expand Up @@ -32,8 +32,8 @@

#import <Foundation/Foundation.h>

@class AFHTTPClient;
@class AFHTTPRequestOperation;
@class AFHTTPRequestOperationManager;

@class EWCacheManager;
@protocol EWCacheManagerDelegate
Expand All @@ -58,7 +58,7 @@

@property(nonatomic, weak) id<EWCacheManagerDelegate> delegate;

@property(nonatomic, strong) AFHTTPClient *downloadClient;
@property(nonatomic, strong) AFHTTPRequestOperationManager *downloadClient;
@property(nonatomic, strong) NSURL *baseURL;

@property(readonly) float fileProgress;
Expand Down Expand Up @@ -109,21 +109,27 @@
- (void)deleteFileInCache:(NSString *)filename;

/**
* Description
* Initiates a download request with the specified request and filename,
* executing success() and failure() as appropriate, if defined.
*
* @param request request description
* @param filename filename description
* @param success success description
* @param request The URL request to make.
* @param filename The filename where the data should be downloaded.
* @param success The block to execute upon sucessfully downloading the
* requested file.
* @param failure The block to execute upon failure (lost connection, data
* corruption, IO error, etc).
*/
- (void)downloadFileWithRequest:(NSURLRequest *)request
filename:(NSString *)filename
success:(void (^)(AFHTTPRequestOperation *operation,
id responseObject))success;
id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation,
NSError *error))failure;

/**
* Description
* Returns the name of the file currently being downloaded.
*
* @return return value description
* @return The filename.
*/
- (NSString *)nameOfFileCurrentlyDownloading;

Expand Down
40 changes: 19 additions & 21 deletions EWCacheManager/EWCacheManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
File: EWCacheManager.m
Version: 1.1
Created: 2013-12-06
Updated: 2014-03-14
Updated: 2014-04-24
Author: Eric Bailey <[email protected]>
Electric Wizardry, LLC <http://electric-wizardry.com>
Expand Down Expand Up @@ -31,11 +31,11 @@ this software and associated documentation files (the "Software"), to deal in
*/

#import "EWCacheManager.h"
#import <AFNetworking/AFHTTPClient.h>
#import <AFNetworking/AFNetworking.h>
#import <AFNetworking/AFHTTPRequestOperation.h>
#import "NSFileManager+DirectoryLocations.h"

@implementation EWCacheManager
@synthesize baseURL = _baseURL;
@synthesize fileProgress = _fileProgress;
@synthesize queueProgress = _queueProgress;

Expand All @@ -48,7 +48,8 @@ + (id)sharedManager {

- (id)init {
if (self = [super init]) {
path = [[NSFileManager defaultManager] applicationSupportDirectory];
path = [NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES) lastObject];

_fileProgress = 0.0f;
_requestedFilesCount = 0;
Expand All @@ -59,7 +60,9 @@ - (id)init {
- (void)downloadFileWithRequest:(NSURLRequest *)request
filename:(NSString *)filename
success:(void (^)(AFHTTPRequestOperation *operation,
id responseObject))success {
id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation,
NSError *error))failure {
dispatch_async(dispatch_get_main_queue(), ^{
self.requestedFilesCount++;
AFHTTPRequestOperation *operation =
Expand Down Expand Up @@ -95,7 +98,7 @@ - (void)downloadFileWithRequest:(NSURLRequest *)request
error:error];
}];

[self.downloadClient enqueueHTTPRequestOperation:operation];
[self.downloadClient.operationQueue addOperation:operation];
});
}

Expand Down Expand Up @@ -137,29 +140,24 @@ - (void)setRequestedFilesCount:(NSUInteger)requestedFilesCount {
_requestedFilesCount = requestedFilesCount;
}

@synthesize baseURL = _baseURL;
- (void)setBaseURL:(NSURL *)baseURL {
_baseURL = baseURL;

_downloadClient = [[AFHTTPClient alloc] initWithBaseURL:_baseURL];
[_downloadClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
[_downloadClient.operationQueue setMaxConcurrentOperationCount:1];
}

@synthesize downloadClient = _downloadClient;
- (AFHTTPClient *)downloadClient {
- (AFHTTPRequestOperationManager *)downloadClient {
NSAssert(_baseURL, @"No base URL set.");

if (!_downloadClient) {
_downloadClient =
[[AFHTTPRequestOperationManager alloc] initWithBaseURL:_baseURL];
[_downloadClient.operationQueue setMaxConcurrentOperationCount:1];
}

return _downloadClient;
}

@synthesize requestedFilesCount = _requestedFilesCount;
- (NSUInteger)requestedFilesCount {
if (self.downloadClient.operationQueue.operationCount > 0) {
return _requestedFilesCount;
}

return 0;
return (self.downloadClient.operationQueue.operationCount > 0)
? _requestedFilesCount
: 0;
}

- (NSString *)nameOfFileCurrentlyDownloading {
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
EWCacheManager
=============

EWCacheManager is a singleton class for convenient cache management, using [AFNetworking](https://github.com/AFNetworking/AFNetworking) for HTTP request management. I ([@yurrriq](https://github.com/yurrriq)) mostly created this for my own use, and to get famililar with the process of writing documentation for Objective-C classes.
EWCacheManager is a singleton class for convenient cache management, using [AFNetworking](https://github.com/AFNetworking/AFNetworking) for HTTP request management. I ([@yurrriq](https://github.com/yurrriq)) mostly created this for my own use, and to get famililar with the process of [writing documentation for Objective-C classes](http://nshipster.com/documentation/).

# Documentation
[EWCacheManager Class Reference](http://electric-wizardry.com/Classes/EWCacheManager.html)

# Dependencies
<big><pre>
[pod](https://github.com/CocoaPods/CocoaPods) '[AFNetworking](https://github.com/AFNetworking/AFNetworking)', '~> [2.2.3](https://github.com/AFNetworking/AFNetworking/releases/tag/2.2.3)'
</pre></big>

# Thanks
- [@AFNetworking](https://github.com/AFNetworking) for [AFNetworking](https://github.com/AFNetworking/AFNetworking), a delightful networking library
- [@mattt](https://github.com/mattt) for [NSFileManager+DirectoryLocations](http://www.cocoawithlove.com/2010/05/finding-or-creating-application-support.html), a category for convenient application support directory handling
- [@tomaz](https://github.com/tomaz) for [appledoc](https://github.com/tomaz/appledoc), a command line tool for generating Apple-like source code documentation
- [@onevcat](https://github.com/onevcat) for [VVDocumenter-Xcode](https://github.com/onevcat/VVDocumenter-Xcode), an Xcode plugin that generates Javadoc style documetation templates by typing `///`

# License
[EWCacheManager](https://github.com/electricwizardry/cache-manager/) is licensed under The MIT License (MIT).
[EWCacheManager](https://github.com/electricwizardry/cache-manager/) is licensed under [The MIT License (MIT)](http://opensource.org/licenses/MIT).

Copyright (c) 2014 Electric Wizardry, LLC
Copyright (c) 2014 [Electric Wizardry, LLC](https://github.com/ElectricWizardry/)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down

0 comments on commit d217528

Please sign in to comment.