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 2012/11/29 00:11:36 UTC

ios commit: Changed unsafe_unretained to weak since we are supporting iOS 5.0 and up only now

Updated Branches:
  refs/heads/master 8724ac6e2 -> 2ba2b3933


Changed unsafe_unretained to weak since we are supporting iOS 5.0 and up only now


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

Branch: refs/heads/master
Commit: 2ba2b39339336e274dd8583f260ff0d85e8e48b2
Parents: 8724ac6
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Nov 28 15:11:36 2012 -0800
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Nov 28 15:11:36 2012 -0800

----------------------------------------------------------------------
 CordovaLib/Classes/CDVCommandDelegateImpl.h |    4 ++--
 CordovaLib/Classes/CDVCommandQueue.h        |    2 +-
 CordovaLib/Classes/CDVContact.m             |    6 +++---
 CordovaLib/Classes/CDVContacts.m            |   12 ++++++------
 CordovaLib/Classes/CDVLocalStorage.m        |    4 ++--
 CordovaLib/Classes/CDVPlugin.h              |    7 +++----
 6 files changed, 17 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/2ba2b393/CordovaLib/Classes/CDVCommandDelegateImpl.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandDelegateImpl.h b/CordovaLib/Classes/CDVCommandDelegateImpl.h
index f850dc6..ee3be39 100644
--- a/CordovaLib/Classes/CDVCommandDelegateImpl.h
+++ b/CordovaLib/Classes/CDVCommandDelegateImpl.h
@@ -25,8 +25,8 @@
 
 @interface CDVCommandDelegateImpl : NSObject <CDVCommandDelegate>{
     @private
-    __unsafe_unretained CDVViewController* _viewController;
-    __unsafe_unretained CDVCommandQueue* _commandQueue;
+    __weak CDVViewController* _viewController;
+    __weak CDVCommandQueue* _commandQueue;
 }
 - (id)initWithViewController:(CDVViewController*)viewController;
 @end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/2ba2b393/CordovaLib/Classes/CDVCommandQueue.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandQueue.h b/CordovaLib/Classes/CDVCommandQueue.h
index d3e2b0a..ebdf844 100644
--- a/CordovaLib/Classes/CDVCommandQueue.h
+++ b/CordovaLib/Classes/CDVCommandQueue.h
@@ -25,7 +25,7 @@
 @interface CDVCommandQueue : NSObject {
     @private
     NSInteger _lastCommandQueueFlushRequestId;
-    __unsafe_unretained CDVViewController* _viewController;
+    __weak CDVViewController* _viewController;
     NSMutableArray* _queue;
     BOOL _currentlyExecuting;
 }

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/2ba2b393/CordovaLib/Classes/CDVContact.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContact.m b/CordovaLib/Classes/CDVContact.m
index 4efc84c..9389207 100644
--- a/CordovaLib/Classes/CDVContact.m
+++ b/CordovaLib/Classes/CDVContact.m
@@ -1146,7 +1146,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
     if (fields == nil) { // no name fields requested
         return nil;
     }
-    id __unsafe_unretained value;
+    id __weak value;
     NSObject* addresses;
     ABMultiValueRef multi = ABRecordCopyValue(self.record, kABPersonAddressProperty);
     CFIndex count = multi ? ABMultiValueGetCount(multi) : 0;
@@ -1221,7 +1221,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
             NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity:3];
             // iOS has label property (work, home, other) for each IM but W3C contact API doesn't use
             CFDictionaryRef dict = (CFDictionaryRef)ABMultiValueCopyValueAtIndex(multi, i);
-            NSString* __unsafe_unretained value;  // all values should be CFStringRefs / NSString*
+            NSString* __weak value;  // all values should be CFStringRefs / NSString*
             bool bFound;
             if ([fields containsObject:kW3ContactFieldValue]) {
                 // value = user name
@@ -1694,7 +1694,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
 
         for (NSString* member in fields) {
             NSString* abKey = [[CDVContact defaultW3CtoAB] valueForKey:member]; // im and address fields are all strings
-            NSString* __unsafe_unretained abValue = nil;
+            NSString* __weak abValue = nil;
             if (abKey) {
                 NSString* testString = nil;
                 if ([member isEqualToString:kW3ContactImType]) {

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/2ba2b393/CordovaLib/Classes/CDVContacts.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContacts.m b/CordovaLib/Classes/CDVContacts.m
index 1e8e084..3faf6ba 100644
--- a/CordovaLib/Classes/CDVContacts.m
+++ b/CordovaLib/Classes/CDVContacts.m
@@ -75,7 +75,7 @@
     NSString* callbackId = command.callbackId;
 
     CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
-    CDVContacts* __unsafe_unretained weakSelf = self;  // play it safe to avoid retain cycles
+    CDVContacts* __weak weakSelf = self;  // play it safe to avoid retain cycles
 
     [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError * errCode) {
             if (addrBook == NULL) {
@@ -128,7 +128,7 @@
     bool bEdit = [options isKindOfClass:[NSNull class]] ? false : [options existsValue:@"true" forKey:@"allowsEditing"];
 
     CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
-    CDVContacts* __unsafe_unretained weakSelf = self;  // play it safe to avoid retain cycles
+    CDVContacts* __weak weakSelf = self;  // play it safe to avoid retain cycles
 
     [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError * errCode) {
             if (addrBook == NULL) {
@@ -288,8 +288,8 @@
             // which is why address book is created within the dispatch queue.
             // more details here: http: //blog.byadrian.net/2012/05/05/ios-addressbook-framework-and-gcd/
             CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
-            CDVContacts* __unsafe_unretained weakSelf = self; // play it safe to avoid retain cycles
-                                                              // it gets uglier, block within block.....
+            CDVContacts* __weak weakSelf = self; // play it safe to avoid retain cycles
+            // it gets uglier, block within block.....
             [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError * errCode) {
                     if (addrBook == NULL) {
                         // permission was denied or other error - return error
@@ -384,7 +384,7 @@
 
     [self.commandDelegate runInBackground:^{
             CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
-            CDVContacts* __unsafe_unretained weakSelf = self; // play it safe to avoid retain cycles
+            CDVContacts* __weak weakSelf = self; // play it safe to avoid retain cycles
 
             [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError * errorCode) {
                     CDVPluginResult* result = nil;
@@ -455,7 +455,7 @@
     NSNumber* cId = [command.arguments objectAtIndex:0];
 
     CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
-    CDVContacts* __unsafe_unretained weakSelf = self;  // play it safe to avoid retain cycles
+    CDVContacts* __weak weakSelf = self;  // play it safe to avoid retain cycles
 
     [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError * errorCode) {
             CDVPluginResult* result = nil;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/2ba2b393/CordovaLib/Classes/CDVLocalStorage.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocalStorage.m b/CordovaLib/Classes/CDVLocalStorage.m
index 531ad4d..217f611 100644
--- a/CordovaLib/Classes/CDVLocalStorage.m
+++ b/CordovaLib/Classes/CDVLocalStorage.m
@@ -23,7 +23,7 @@
 @interface CDVLocalStorage ()
 
 @property (nonatomic, readwrite, strong) NSMutableArray* backupInfo;  // array of CDVBackupInfo objects
-@property (nonatomic, readwrite, unsafe_unretained) id <UIWebViewDelegate> webviewDelegate;
+@property (nonatomic, readwrite, weak) id <UIWebViewDelegate> webviewDelegate;
 
 @end
 
@@ -396,7 +396,7 @@
                 backgroundTaskID = UIBackgroundTaskInvalid;
                 NSLog (@"Background task to backup WebSQL/LocalStorage expired.");
             }];
-        CDVLocalStorage __unsafe_unretained* weakSelf = self;
+        CDVLocalStorage __weak* weakSelf = self;
         [self.commandDelegate runInBackground:^{
                 [weakSelf backup:nil];
 

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/2ba2b393/CordovaLib/Classes/CDVPlugin.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin.h b/CordovaLib/Classes/CDVPlugin.h
index f9b1377..3c0769d 100644
--- a/CordovaLib/Classes/CDVPlugin.h
+++ b/CordovaLib/Classes/CDVPlugin.h
@@ -28,11 +28,10 @@
 
 @interface CDVPlugin : NSObject {}
 
-// TODO(agrieve): Make these zeroing weak refs once we drop support for 4.3.
-@property (nonatomic, unsafe_unretained) UIWebView* webView;
+@property (nonatomic, weak) UIWebView* webView;
 @property (nonatomic, strong) NSDictionary* settings;
-@property (nonatomic, unsafe_unretained) UIViewController* viewController;
-@property (nonatomic, unsafe_unretained) id <CDVCommandDelegate> commandDelegate;
+@property (nonatomic, weak) UIViewController* viewController;
+@property (nonatomic, weak) id <CDVCommandDelegate> commandDelegate;
 
 @property (readonly, assign) BOOL hasPendingOperation;