cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject git commit: Remove deprecated symbols for iOS < 6
Date Wed, 04 Jun 2014 18:25:42 GMT
Repository: cordova-plugin-contacts
Updated Branches:
  refs/heads/master 313681958 -> 08fe76741


Remove deprecated symbols for iOS < 6


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/commit/08fe7674
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/08fe7674
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/08fe7674

Branch: refs/heads/master
Commit: 08fe76741d5b6e3989d39d1a6b884643af2b41ca
Parents: 3136819
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Wed Jun 4 14:22:41 2014 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Wed Jun 4 14:22:41 2014 -0400

----------------------------------------------------------------------
 src/ios/CDVContacts.m | 102 +++++++++++----------------------------------
 1 file changed, 25 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/08fe7674/src/ios/CDVContacts.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVContacts.m b/src/ios/CDVContacts.m
index 880550a..7f3ef32 100644
--- a/src/ios/CDVContacts.m
+++ b/src/ios/CDVContacts.m
@@ -91,13 +91,7 @@
 
         UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:npController];
 
-        SEL selector = NSSelectorFromString(@"presentViewController:animated:completion:");
-        if ([weakSelf.viewController respondsToSelector:selector]) {
-            [weakSelf.viewController presentViewController:navController animated:YES completion:nil];
-        } else {
-            // deprecated as of iOS >= 6.0
-            [weakSelf.viewController presentModalViewController:navController animated:YES];
-        }
+        [weakSelf.viewController presentViewController:navController animated:YES completion:nil];
     }];
 }
 
@@ -112,11 +106,7 @@
         recordId = ABRecordGetRecordID(person);
     }
 
-    if ([newPersonViewController respondsToSelector:@selector(presentingViewController)])
{
-        [[newPersonViewController presentingViewController] dismissViewControllerAnimated:YES
completion:nil];
-    } else {
-        [[newPersonViewController parentViewController] dismissModalViewControllerAnimated:YES];
-    }
+    [[newPersonViewController presentingViewController] dismissViewControllerAnimated:YES
completion:nil];
 
     CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:recordId];
     [self.commandDelegate sendPluginResult:result callbackId:callbackId];
@@ -153,13 +143,7 @@
 
             [navController pushViewController:personController animated:YES];
 
-            SEL selector = NSSelectorFromString(@"presentViewController:animated:completion:");
-            if ([self.viewController respondsToSelector:selector]) {
-                [self.viewController presentViewController:navController animated:YES completion:nil];
-            } else {
-                // deprecated as of iOS >= 6.0
-                [self.viewController presentModalViewController:navController animated:YES];
-            }
+            [self.viewController presentViewController:navController animated:YES completion:nil];
 
             if (bEdit) {
                 // create the editing controller and push it onto the stack
@@ -202,13 +186,7 @@
     }
     pickerController.allowsEditing = allowsEditing;
 
-    SEL selector = NSSelectorFromString(@"presentViewController:animated:completion:");
-    if ([self.viewController respondsToSelector:selector]) {
-        [self.viewController presentViewController:pickerController animated:YES completion:nil];
-    } else {
-        // deprecated as of iOS >= 6.0
-        [self.viewController presentModalViewController:pickerController animated:YES];
-    }
+    [self.viewController presentViewController:pickerController animated:YES completion:nil];
 }
 
 - (void)pickContact:(CDVInvokedUrlCommand *)command
@@ -259,11 +237,7 @@
         CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:picker.pickedContactDictionary];
         [self.commandDelegate sendPluginResult:result callbackId:picker.callbackId];
 
-        if ([picker respondsToSelector:@selector(presentingViewController)]) {
-            [[picker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
-        } else {
-            [[picker parentViewController] dismissModalViewControllerAnimated:YES];
-        }
+        [[picker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
     }
     return NO;
 }
@@ -282,16 +256,7 @@
     if (picker.allowsEditing) {
         // get the info after possible edit
         // if we got this far, user has already approved/ disapproved addressBook access
-        ABAddressBookRef addrBook = nil;
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
-            if (&ABAddressBookCreateWithOptions != NULL) {
-                addrBook = ABAddressBookCreateWithOptions(NULL, NULL);
-            } else
-#endif
-        {
-            // iOS 4 & 5
-            addrBook = ABAddressBookCreate();
-        }
+        ABAddressBookRef addrBook = ABAddressBookCreateWithOptions(NULL, NULL);
         ABRecordRef person = ABAddressBookGetPersonWithRecordID(addrBook, (int)[[picker.pickedContactDictionary
objectForKey:kW3ContactId] integerValue]);
         if (person) {
             CDVContact* pickedContact = [[CDVContact alloc] initFromABRecord:(ABRecordRef)person];
@@ -304,11 +269,7 @@
     CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:picker.pickedContactDictionary];
     [self.commandDelegate sendPluginResult:result callbackId:picker.callbackId];
 
-    if ([peoplePicker respondsToSelector:@selector(presentingViewController)]) {
-        [[peoplePicker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
-    } else {
-        [[peoplePicker parentViewController] dismissModalViewControllerAnimated:YES];
-    }
+    [[peoplePicker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
 }
 
 - (void)search:(CDVInvokedUrlCommand*)command
@@ -568,11 +529,7 @@
 {
     [super viewWillDisappear:animated];
 
-    if ([self respondsToSelector:@selector(presentingViewController)]) {
-        [[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
-    } else {
-        [[self parentViewController] dismissModalViewControllerAnimated:YES];
-    }
+    [[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
 }
 
 @end
@@ -603,32 +560,23 @@
     // "Important: Instances of ABAddressBookRef cannot be used by multiple threads. Each
thread must make its own instance."
     ABAddressBookRef addressBook;
 
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
-        if (&ABAddressBookCreateWithOptions != NULL) {
-            CFErrorRef error = nil;
-            // CFIndex status = ABAddressBookGetAuthorizationStatus();
-            addressBook = ABAddressBookCreateWithOptions(NULL, &error);
-            // NSLog(@"addressBook access: %lu", status);
-            ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef
error) {
-                    // callback can occur in background, address book must be accessed on
thread it was created on
-                    dispatch_sync(dispatch_get_main_queue(), ^{
-                        if (error) {
-                            workerBlock(NULL, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]);
-                        } else if (!granted) {
-                            workerBlock(NULL, [[CDVAddressBookAccessError alloc] initWithCode:PERMISSION_DENIED_ERROR]);
-                        } else {
-                            // access granted
-                            workerBlock(addressBook, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]);
-                        }
-                    });
-                });
-        } else
-#endif
-    {
-        // iOS 4 or 5 no checks needed
-        addressBook = ABAddressBookCreate();
-        workerBlock(addressBook, NULL);
-    }
+    CFErrorRef error = nil;
+    // CFIndex status = ABAddressBookGetAuthorizationStatus();
+    addressBook = ABAddressBookCreateWithOptions(NULL, &error);
+    // NSLog(@"addressBook access: %lu", status);
+    ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error)
{
+            // callback can occur in background, address book must be accessed on thread
it was created on
+            dispatch_sync(dispatch_get_main_queue(), ^{
+                if (error) {
+                    workerBlock(NULL, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]);
+                } else if (!granted) {
+                    workerBlock(NULL, [[CDVAddressBookAccessError alloc] initWithCode:PERMISSION_DENIED_ERROR]);
+                } else {
+                    // access granted
+                    workerBlock(addressBook, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]);
+                }
+            });
+        });
 }
 
 @end


Mime
View raw message