cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject ios commit: CB-7857 - Load appURL after plugins have loaded
Date Thu, 23 Oct 2014 19:43:12 GMT
Repository: cordova-ios
Updated Branches:
  refs/heads/master 01b3d191d -> 1b85a6e67


CB-7857 - Load appURL after plugins have loaded

- includes uncrustify style fixups


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

Branch: refs/heads/master
Commit: 1b85a6e6762ef1280651a6e52358298b3d2a0ed7
Parents: 01b3d19
Author: Shazron Abdullah <shazron@apache.org>
Authored: Thu Oct 23 12:43:13 2014 -0700
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Thu Oct 23 12:43:13 2014 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDVViewController.m | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1b85a6e6/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index acb88f7..8cd59b3 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -199,13 +199,9 @@
     self.pluginObjects = [[NSMutableDictionary alloc] initWithCapacity:20];
 }
 
-// Implement viewDidLoad to do additional setup after loading the view, typically from a
nib.
-- (void)viewDidLoad
+- (NSURL*)appUrl
 {
-    [super viewDidLoad];
-
     NSURL* appURL = nil;
-    NSString* loadErr = nil;
 
     if ([self.startPage rangeOfString:@"://"].location != NSNotFound) {
         appURL = [NSURL URLWithString:self.startPage];
@@ -217,8 +213,6 @@
         NSString* startFilePath = [self.commandDelegate pathForResource:[startURL path]];
 
         if (startFilePath == nil) {
-            loadErr = [NSString stringWithFormat:@"ERROR: Start Page at '%@/%@' was not found.",
self.wwwFolderName, self.startPage];
-            NSLog(@"%@", loadErr);
             self.loadFromString = YES;
             appURL = nil;
         } else {
@@ -233,6 +227,14 @@
         }
     }
 
+    return appURL;
+}
+
+// Implement viewDidLoad to do additional setup after loading the view, typically from a
nib.
+- (void)viewDidLoad
+{
+    [super viewDidLoad];
+
     // // Fix the iOS 5.1 SECURITY_ERR bug (CB-347), this must be before the webView is instantiated
////
 
     NSString* backupWebStorageType = @"cloud"; // default value
@@ -315,7 +317,7 @@
     }
 
     NSString* decelerationSetting = [self settingForKey:@"UIWebViewDecelerationSpeed"];
-    if (![@"fast" isEqualToString : decelerationSetting]) {
+    if (![@"fast" isEqualToString:decelerationSetting]) {
         [self.webView.scrollView setDecelerationRate:UIScrollViewDecelerationRateNormal];
     }
 
@@ -437,13 +439,18 @@
     }
 
     // /////////////////
+    NSURL* appURL = [self appUrl];
+
     [CDVUserAgentUtil acquireLock:^(NSInteger lockToken) {
         _userAgentLockToken = lockToken;
         [CDVUserAgentUtil setUserAgent:self.userAgent lockToken:lockToken];
-        if (!loadErr) {
+        if (appURL) {
             NSURLRequest* appReq = [NSURLRequest requestWithURL:appURL cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:20.0];
             [self.webView loadRequest:appReq];
         } else {
+            NSString* loadErr = [NSString stringWithFormat:@"ERROR: Start Page at '%@/%@'
was not found.", self.wwwFolderName, self.startPage];
+            NSLog(@"%@", loadErr);
+
             NSString* html = [NSString stringWithFormat:@"<html><body> %@ </body></html>",
loadErr];
             [self.webView loadHTMLString:html baseURL:nil];
         }
@@ -781,7 +788,7 @@
 + (NSString*)applicationDocumentsDirectory
 {
     NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,
YES);
-    NSString* basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
+    NSString* basePath = ([paths count] > 0) ? (([paths objectAtIndex : 0]) : nil);
 
     return basePath;
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message