You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2015/10/29 01:02:58 UTC

ios commit: CB-9893 - Update API changes doc with more upgrade examples

Repository: cordova-ios
Updated Branches:
  refs/heads/master 67b28d767 -> 5ef74123f


CB-9893 - Update API changes doc with more upgrade examples


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

Branch: refs/heads/master
Commit: 5ef74123fda613483ea1692afe7aaa724f7166c1
Parents: 67b28d7
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Oct 28 17:02:51 2015 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Oct 28 17:02:51 2015 -0700

----------------------------------------------------------------------
 guides/API changes in 4.0.md | 215 +++++++++++++++++++++++++++++++++++---
 1 file changed, 202 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/5ef74123/guides/API changes in 4.0.md
----------------------------------------------------------------------
diff --git a/guides/API changes in 4.0.md b/guides/API changes in 4.0.md
index f6f96f1..ba41777 100644
--- a/guides/API changes in 4.0.md	
+++ b/guides/API changes in 4.0.md	
@@ -1,10 +1,28 @@
-#API Changes
-
-* CDVViewController.h
-* CDVPlugin.h
-
-
-## CDVViewController.h
+# API Changes in cordova-ios-4.0
+
+* CDVViewController.h (_updated_)
+* CDVPlugin.h (_updated_)
+* CDVPluginResult.h (_updated_)
+* NSData+Base64.h (_removed_)
+* CDVAppDelegate.h (_new_) 
+* CDVJSON.h (_removed_)
+* CDVJSON\_private.h (_removed_)
+* CDVWebViewEngineProtocol.h (_new_)
+* CDVURLRequestFilter.h (_new_)
+* NSDictionary+CordovaPreferences.h (_new_)
+* CDVWebViewDelegate.h (_removed_)
+* NSDictionary+Extensions.h (_removed_)
+* NSArray+Comparisons.h (_removed_)
+* CDVHandleOpenURL.h (_removed_)
+* CDVLocalStorage.h (_removed_)
+* UIDevice+Extensions.h (_removed_)
+* CDVShared.h (_removed_)
+* CDVDebug.h (_removed_)
+* Conditional Compilation
+
+- - -
+
+## CDVViewController.h (_updated_)
 
 
 ### Removed:
@@ -38,7 +56,20 @@ Properties:
 
     @property UIView* webView
 
-## CDVPlugin.h
+### Upgrade Notes:
+
+The `webView` property is a `UIView` now, to take into account the different type of WebView engines that might be installed. 
+
+To test and cast the `webView` property to `UIWebView`:
+
+    if ([self.webView isKindOfClass:[UIWebView class]) {
+        // call a UIWebView specific method here, for example
+        [((UIWebView*)self.webView) goBack];
+    }
+
+- - -
+
+## CDVPlugin.h (_updated_)
 
 ### Removed:
 
@@ -80,7 +111,29 @@ Methods:
     - (BOOL)shouldAllowNavigationToURL:(NSURL *)url
     - (BOOL)shouldOpenExternalURL:(NSURL *)url
 
-## CDVPluginResult.h
+### Upgrade Notes:
+
+Put your initialization code from `initWithWebView` into `pluginInitialize`. `pluginInitialize` is backwards-compatible, it has been there since cordova-ios-2.x. 
+
+For example, if you have this:
+
+    - (CDVPlugin*) initWithWebView:(UIWebView*)webView {
+        self = [super initWithWebView:webView];
+        if (self) {
+            // Initialization code here
+        }
+        return self;
+    }
+ 
+ Move your initialization code to:
+ 
+    - (void) pluginInitialize {
+        // Initialization code here
+    }
+
+- - -
+
+## CDVPluginResult.h (_updated_)
 
 ### Added:
 
@@ -90,7 +143,9 @@ Methods:
     + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsNSUInteger:(NSUInteger)theMessage;
 
 
-## NSData+Base64.h
+- - -
+
+## NSData+Base64.h (_removed_)
 
 This class has been removed.
 
@@ -113,10 +168,144 @@ Plugin authors are encouraged to use the (iOS 7+) base64 encoding and decoding m
     // Encode a string to Base64
     NSString* encodedString = [data base64EncodedStringWithOptions:0];
 
-## CDVAppDelegate.h
+- - -
 
-This class is new. The default template's AppDelegate class inherits from this now for you to override.
+## CDVAppDelegate.h (_new_)
+
+This class is new. The default template's `AppDelegate` class inherits from this now for you to override.
     
 ### Upgrade Notes:
 
-Apps that add code in the default template's old AppDelegate.m should add the appropriate function override in the new AppDelegate.m. Don't forget to call the superclass' implementation as well in your override.
\ No newline at end of file
+Apps that add code in the default template's old `AppDelegate.m` should add the appropriate function override in the new `AppDelegate.m`. Don't forget to call the superclass' implementation as well in your override.
+
+- - -
+
+## CDVJSON.h (_removed_)
+
+These Objective-C Categories have been **removed**. 
+
+### Upgrade Notes:
+
+To convert from an NSArray/NSDictionary object to a JSON string:
+
+    id object; // this is the NSArray/NSDictionary to convert from
+    NSError* error = nil;
+    NSString* jsonString = nil;
+    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:object
+                                                       options:NSJSONWritingPrettyPrinted
+                                                         error:&error];
+                                                         
+    if (error == nil) {
+        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
+    }
+
+To convert from an NSString to an NSArray/NSDictionary object:
+
+    NSString* jsonString; // this is the JSON to convert from
+    NSError* error = nil;
+    id object = [NSJSONSerialization JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding]
+                                                options:NSJSONReadingMutableContainers
+                                                  error:&error];
+
+    if (error != nil) {
+        NSLog(@"NSString can't be converted to an NSArray/NSDictionary error: %@", [error localizedDescription]);
+    }
+
+- - -
+
+## CDVJSON\_private.h (_removed_)
+
+These Objective-C Categories have been **removed** from the public API, and is private to CordovaLib.
+
+- - -
+
+## CDVWebViewEngineProtocol.h (_new_)
+
+This is new in cordova-ios-4.0. An Objective-C protocol for plugins to implement, if they want to be an alternative WebView engine.
+
+- - -
+
+## CDVURLRequestFilter.h (_new_)
+
+This is new in cordova-ios-4.0. An Objective-C protocol that plugins can implement. The methods in the protocol are called in all plugins (if available) to veto a navigation, request, or an external request to open a URL. 
+
+- - -
+
+## NSDictionary+CordovaPreferences.h (_new_)
+
+This is new in cordova-ios-4.0. An Objective-C Category helper for NSDictionary to get/set preferences.
+
+- - -
+
+## CDVWebViewDelegate.h (_removed_)
+
+This protocol has been **removed** from the public API, and is part of a private plugin to CordovaLib (CDVUIWebViewEngine).
+
+- - -
+
+## NSDictionary+Extensions.h (_removed_)
+
+This Objective-C Category has been **removed**.
+
+- - -
+
+## NSArray+Comparisons.h (_removed_)
+
+This Objective-C category has been **removed**. 
+
+### Upgrade Notes:
+
+The Objective-C Category method was used as a helper for the `arguments` property of a `CDVInvokedURLCommand` object. Use the `argumentAtIndex` [methods provided](https://github.com/apache/cordova-ios/blob/master/CordovaLib/Classes/Public/CDVInvokedUrlCommand.h) in the `CDVInvokedURLCommand` object instead. 
+
+"Use [command argumentAtIndex] instead.")
+
+- - -
+
+## CDVHandleOpenURL.h (_removed_)
+
+This plugin has been **removed** from the public API, and is now private to CordovaLib.
+
+- - -
+
+## CDVLocalStorage.h (_removed_)
+
+This plugin has been **removed** from the public API, and is now private to CordovaLib.
+
+- - -
+
+## UIDevice+Extensions.h (_removed_)
+
+This implementation has been **removed** and is part of the core plugin `cordova-plugin-device`.
+
+- - -
+
+## CDVShared.h (_removed_)
+
+This legacy header has been **removed**; it was for core plugin compatibility that has been not been needed [since the Aug 2014 core plugin release](https://cordova.apache.org/news/2014/08/11/plugins-release.html).
+
+- - -
+
+## CDVDebug.h (_removed_)
+
+This file has been **removed** from the public API, and is private to CordovaLib.
+
+- - -
+
+## Conditional Compilation
+
+You can conditionally compile code based on the cordova-ios platform version that is installed. This might be for API calls that have no backwards-compatible equivalents. 
+
+    // this import below must be declared first
+    #import <Cordova/CDVAvailability.h>
+    
+    #ifdef __CORDOVA_4_0_0
+        // Execute/declare code on cordova-ios-4.x or newer 
+    #else
+        // Execute/declare code for cordova-ios versions *less than* 4.x 
+    #endif
+ 
+ OR
+
+    #ifndef __CORDOVA_4_0_0
+        // Execute/declare code for cordova-ios versions *less than* 4.x 
+    #endif


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