You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/02/13 18:38:56 UTC

ios commit: [CB-2275] Add NSURLCache to app template.

Updated Branches:
  refs/heads/master 299a324e8 -> 4001ae13f


[CB-2275] Add NSURLCache to app template.


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/4001ae13
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/4001ae13
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/4001ae13

Branch: refs/heads/master
Commit: 4001ae13fcb1fcbe73168327630fbc0ce44703d0
Parents: 299a324
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Feb 13 12:38:20 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Feb 13 12:38:20 2013 -0500

----------------------------------------------------------------------
 .../project/__TESTING__/Classes/AppDelegate.m      |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/4001ae13/bin/templates/project/__TESTING__/Classes/AppDelegate.m
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Classes/AppDelegate.m b/bin/templates/project/__TESTING__/Classes/AppDelegate.m
index 6dc7bfc..318f793 100644
--- a/bin/templates/project/__TESTING__/Classes/AppDelegate.m
+++ b/bin/templates/project/__TESTING__/Classes/AppDelegate.m
@@ -43,6 +43,11 @@
 
     [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
 
+    int cacheSizeMemory = 8 * 1024 * 1024; // 8MB
+    int cacheSizeDisk = 32 * 1024 * 1024; // 32MB
+    NSURLCache* sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"];
+    [NSURLCache setSharedURLCache:sharedCache];
+
     self = [super init];
     return self;
 }
@@ -109,4 +114,9 @@
     return supportedInterfaceOrientations;
 }
 
+- (void)applicationDidReceiveMemoryWarning:(UIApplication*)application
+{
+    [[NSURLCache sharedURLCache] removeAllCachedResponses];
+}
+
 @end