You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by be...@apache.org on 2012/08/02 14:20:01 UTC
[2/3] ios commit: Changes for ARC
Changes for ARC
Changed retain properties to strong. Removed release and retain calls as well as dealloc.
Used __autoreleasing for NSError passed by reference. Updated for bridging to Core Foundation classes.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/a6b67bea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/a6b67bea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/a6b67bea
Branch: refs/heads/master
Commit: a6b67bea11c5dbd17a4efecc87717e2300f3d700
Parents: 446d456
Author: Becky Gibson <be...@apache.org>
Authored: Thu Jun 7 17:12:01 2012 -0400
Committer: Becky Gibson <be...@apache.org>
Committed: Wed Aug 1 16:34:08 2012 -0400
----------------------------------------------------------------------
CordovaLib/Classes/CDVAccelerometer.h | 2 +-
CordovaLib/Classes/CDVAccelerometer.m | 1 -
CordovaLib/Classes/CDVBattery.h | 2 +-
CordovaLib/Classes/CDVBattery.m | 2 -
CordovaLib/Classes/CDVCamera.h | 8 +-
CordovaLib/Classes/CDVCamera.m | 19 +--
CordovaLib/Classes/CDVCapture.h | 26 ++--
CordovaLib/Classes/CDVCapture.m | 69 +-------
CordovaLib/Classes/CDVConnection.h | 2 +-
CordovaLib/Classes/CDVConnection.m | 2 -
CordovaLib/Classes/CDVContact.h | 7 +-
CordovaLib/Classes/CDVContact.m | 131 +++++----------
CordovaLib/Classes/CDVContacts.h | 4 +-
CordovaLib/Classes/CDVContacts.m | 61 +++-----
CordovaLib/Classes/CDVCordovaView.h | 2 -
CordovaLib/Classes/CDVCordovaView.m | 3 -
CordovaLib/Classes/CDVDevice.m | 4 +-
CordovaLib/Classes/CDVFile.h | 10 +-
CordovaLib/Classes/CDVFile.m | 62 ++------
CordovaLib/Classes/CDVFileTransfer.h | 4 +-
CordovaLib/Classes/CDVFileTransfer.m | 31 +---
CordovaLib/Classes/CDVInvokedUrlCommand.m | 20 +--
CordovaLib/Classes/CDVLocalStorage.h | 2 +-
CordovaLib/Classes/CDVLocalStorage.m | 58 +++----
CordovaLib/Classes/CDVLocation.h | 18 +-
CordovaLib/Classes/CDVLocation.m | 28 +---
CordovaLib/Classes/CDVMotion.m | 4 -
CordovaLib/Classes/CDVNotification.h | 2 -
CordovaLib/Classes/CDVNotification.m | 6 -
CordovaLib/Classes/CDVPlugin.h | 8 +-
CordovaLib/Classes/CDVPlugin.m | 3 -
CordovaLib/Classes/CDVPluginResult.h | 8 +-
CordovaLib/Classes/CDVPluginResult.m | 32 +---
CordovaLib/Classes/CDVReachability.m | 21 +--
CordovaLib/Classes/CDVSound.h | 14 +-
CordovaLib/Classes/CDVSound.m | 42 +----
CordovaLib/Classes/CDVURLProtocol.m | 9 +-
CordovaLib/Classes/CDVViewController.h | 18 +-
CordovaLib/Classes/CDVViewController.m | 50 +++---
CordovaLib/Classes/CDVWhitelist.h | 4 +-
CordovaLib/Classes/CDVWhitelist.m | 8 +-
CordovaLib/Classes/NSData+Base64.m | 5 +-
CordovaLib/Classes/NSMutableArray+QueueAdditions.m | 4 +-
CordovaLib/Classes/UIDevice+Extensions.m | 2 +-
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 4 +-
.../CDVPluginResultJSONSerializationTests.m | 2 +-
CordovaLib/CordovaLibTests/CDVWebViewTest.h | 4 +
CordovaLib/CordovaLibTests/CDVWhitelistTests.m | 28 +---
.../project/__TESTING__.xcodeproj/project.pbxproj | 4 +
.../project/__TESTING__/Classes/AppDelegate.h | 4 +-
.../project/__TESTING__/Classes/AppDelegate.m | 12 +-
bin/templates/project/__TESTING__/main.m | 8 +-
52 files changed, 296 insertions(+), 588 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVAccelerometer.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVAccelerometer.h b/CordovaLib/Classes/CDVAccelerometer.h
index 16f6200..f62fb82 100755
--- a/CordovaLib/Classes/CDVAccelerometer.h
+++ b/CordovaLib/Classes/CDVAccelerometer.h
@@ -31,7 +31,7 @@
}
@property (readonly, assign) BOOL isRunning;
-@property (nonatomic, retain) NSString* callbackId;
+@property (nonatomic, strong) NSString* callbackId;
- (CDVAccelerometer*) init;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVAccelerometer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVAccelerometer.m b/CordovaLib/Classes/CDVAccelerometer.m
index 3843bab..77b863a 100644
--- a/CordovaLib/Classes/CDVAccelerometer.m
+++ b/CordovaLib/Classes/CDVAccelerometer.m
@@ -52,7 +52,6 @@
- (void) dealloc {
[self stop:nil withDict:nil];
- [super dealloc]; // pretty important.
}
- (void)start:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVBattery.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVBattery.h b/CordovaLib/Classes/CDVBattery.h
index ae04069..5cc765c 100644
--- a/CordovaLib/Classes/CDVBattery.h
+++ b/CordovaLib/Classes/CDVBattery.h
@@ -31,7 +31,7 @@
@property (nonatomic) UIDeviceBatteryState state;
@property (nonatomic) float level;
@property (nonatomic) bool isPlugged;
-@property (retain) NSString* callbackId;
+@property (strong) NSString* callbackId;
- (void) updateBatteryStatus:(NSNotification*)notification;
- (NSDictionary*) getBatteryStatus;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVBattery.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVBattery.m b/CordovaLib/Classes/CDVBattery.m
index efd3d39..8a74ad3 100644
--- a/CordovaLib/Classes/CDVBattery.m
+++ b/CordovaLib/Classes/CDVBattery.m
@@ -149,8 +149,6 @@
- (void)dealloc
{
[self stop: NULL withDict:NULL];
-
- [super dealloc];
}
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVCamera.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.h b/CordovaLib/Classes/CDVCamera.h
index fa38764..d7f17ad 100644
--- a/CordovaLib/Classes/CDVCamera.h
+++ b/CordovaLib/Classes/CDVCamera.h
@@ -49,15 +49,14 @@ typedef NSUInteger CDVMediaType;
@property (copy) NSString* postUrl;
@property (nonatomic) enum CDVDestinationType returnType;
@property (nonatomic) enum CDVEncodingType encodingType;
-@property (retain) UIPopoverController* popoverController;
+@property (strong) UIPopoverController* popoverController;
@property (assign) CGSize targetSize;
@property (assign) bool correctOrientation;
@property (assign) bool saveToPhotoAlbum;
@property (assign) bool cropToSize;
-@property (retain) UIWebView* webView;
+@property (strong) UIWebView* webView;
@property (assign) BOOL popoverSupported;
-- (void) dealloc;
@end
@@ -69,7 +68,7 @@ typedef NSUInteger CDVMediaType;
{
}
-@property (retain) CDVCameraPicker* pickerController;
+@property (strong) CDVCameraPicker* pickerController;
/*
* getPicture
@@ -93,7 +92,6 @@ typedef NSUInteger CDVMediaType;
- (UIImage*)imageCorrectedForCaptureOrientation:(UIImage*)anImage;
- (void) closePicker:(CDVCameraPicker*)picker __attribute__((deprecated));
-- (void) dealloc;
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVCamera.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.m b/CordovaLib/Classes/CDVCamera.m
index b9c0bad..cc691a0 100644
--- a/CordovaLib/Classes/CDVCamera.m
+++ b/CordovaLib/Classes/CDVCamera.m
@@ -44,7 +44,7 @@ static NSSet* org_apache_cordova_validArrowDirections;
- (BOOL) popoverSupported
{
return ( NSClassFromString(@"UIPopoverController") != nil) &&
- (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
+ (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
}
/* takePicture arguments:
@@ -128,8 +128,7 @@ static NSSet* org_apache_cordova_validArrowDirections;
{
if (cameraPicker.popoverController == nil)
{
- cameraPicker.popoverController = [[[NSClassFromString(@"UIPopoverController") alloc]
- initWithContentViewController:cameraPicker] autorelease];
+ cameraPicker.popoverController = [[NSClassFromString(@"UIPopoverController") alloc] initWithContentViewController:cameraPicker];
}
int x = 0;
int y = 32;
@@ -163,7 +162,6 @@ static NSSet* org_apache_cordova_validArrowDirections;
}
}
self.hasPendingOperation = YES;
- [cameraPicker release];
}
- (void) cleanup:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
@@ -192,8 +190,7 @@ static NSSet* org_apache_cordova_validArrowDirections;
NSLog(@"Failed to delete: %@ (error: %@)", filePath, err);
hasErrors = YES;
}
- }
- [fileMgr release];
+ }
if (hasErrors) {
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:@"One or more files failed to be deleted."];
@@ -311,7 +308,6 @@ static NSSet* org_apache_cordova_validArrowDirections;
result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString: [[NSURL fileURLWithPath: filePath] absoluteString]];
jsString = [result toSuccessCallbackString:callbackId];
}
- [fileMgr release];
} else {
result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString: [data base64EncodedString]];
@@ -559,10 +555,6 @@ static NSSet* org_apache_cordova_validArrowDirections;
}
-- (void) dealloc
-{
- [super dealloc];
-}
@end
@@ -581,9 +573,4 @@ static NSSet* org_apache_cordova_validArrowDirections;
@synthesize webView;
@synthesize popoverSupported;
-- (void) dealloc
-{
- [super dealloc];
-}
-
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVCapture.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCapture.h b/CordovaLib/Classes/CDVCapture.h
index 20b376c..5ade19d 100644
--- a/CordovaLib/Classes/CDVCapture.h
+++ b/CordovaLib/Classes/CDVCapture.h
@@ -43,9 +43,6 @@ typedef NSUInteger CDVCaptureError;
@property (copy) NSString* callbackId;
@property (copy) NSString* mimeType;
-
-- (void) dealloc;
-
@end
@interface CDVCapture : CDVPlugin<UIImagePickerControllerDelegate, UINavigationControllerDelegate>
@@ -66,7 +63,6 @@ typedef NSUInteger CDVCaptureError;
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo;
- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker;
-- (void) dealloc;
@end
/* AudioRecorderViewController is used to create a simple view for audio recording.
* It is created from [Capture captureAudio]. It creates a very simple interface for
@@ -97,17 +93,17 @@ typedef NSUInteger CDVCaptureError;
@property (nonatomic) CDVCaptureError errorCode;
@property (nonatomic, copy) NSString* callbackId;
@property (nonatomic, copy) NSNumber* duration;
-@property (nonatomic, retain) CDVCapture* captureCommand;
-@property (nonatomic, retain) UIBarButtonItem* doneButton;
-@property (nonatomic, retain) UIView* recordingView;
-@property (nonatomic, retain) UIButton* recordButton;
-@property (nonatomic, retain) UIImage* recordImage;
-@property (nonatomic, retain) UIImage* stopRecordImage;
-@property (nonatomic, retain) UILabel* timerLabel;
-@property (nonatomic, retain) AVAudioRecorder* avRecorder;
-@property (nonatomic, retain) AVAudioSession* avSession;
-@property (nonatomic, retain) NSString* resultString;
-@property (nonatomic, retain) NSTimer* timer;
+@property (nonatomic, strong) CDVCapture* captureCommand;
+@property (nonatomic, strong) UIBarButtonItem* doneButton;
+@property (nonatomic, strong) UIView* recordingView;
+@property (nonatomic, strong) UIButton* recordButton;
+@property (nonatomic, strong) UIImage* recordImage;
+@property (nonatomic, strong) UIImage* stopRecordImage;
+@property (nonatomic, strong) UILabel* timerLabel;
+@property (nonatomic, strong) AVAudioRecorder* avRecorder;
+@property (nonatomic, strong) AVAudioSession* avSession;
+@property (nonatomic, strong) NSString* resultString;
+@property (nonatomic, strong) NSTimer* timer;
@property (nonatomic) BOOL isTimed;
- (id) initWithCommand: (CDVPlugin*) theCommand duration: (NSNumber*) theDuration callbackId: (NSString*) theCallbackId;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVCapture.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCapture.m b/CordovaLib/Classes/CDVCapture.m
index dbdd6b1..1627085 100644
--- a/CordovaLib/Classes/CDVCapture.m
+++ b/CordovaLib/Classes/CDVCapture.m
@@ -45,19 +45,6 @@
return UIAccessibilityTraitNone;
}
-- (void) dealloc
-{
- if (callbackId) {
- [callbackId release];
- }
- if (mimeType) {
- [mimeType release];
- }
-
-
- [super dealloc];
-}
-
@end
@implementation CDVCapture
@@ -89,10 +76,10 @@
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageToErrorObject: CAPTURE_APPLICATION_BUSY];
} else {
// all the work occurs here
- CDVAudioRecorderViewController* audioViewController = [[[CDVAudioRecorderViewController alloc] initWithCommand: self duration: duration callbackId: callbackId] autorelease];
+ CDVAudioRecorderViewController* audioViewController = [[CDVAudioRecorderViewController alloc] initWithCommand: self duration: duration callbackId: callbackId];
// Now create a nav controller and display the view...
- UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:audioViewController] autorelease];
+ UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:audioViewController];
self.inUse = YES;
if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
@@ -203,7 +190,6 @@
jsString = [result toSuccessCallbackString:callbackId];
}
- [fileMgr release];
return jsString;
}
@@ -217,9 +203,6 @@
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
// there is a camera, it is available, make sure it can do movies
- if (pickerController != nil) {
- [pickerController release]; // create a new one for each instance to initialize all variables
- }
pickerController = [[CDVImagePicker alloc] init];
NSArray* types = nil;
@@ -400,7 +383,6 @@
// not sure how to get codecs or bitrate???
//AVMetadataItem
//AudioFile
- [movieAsset release];
} else if ([mimeType rangeOfString: @"audio/"].location != NSNotFound) {
if (NSClassFromString(@"AVAudioPlayer") != nil) {
@@ -419,9 +401,6 @@
}
}
} // else leave data init'ed to 0
- if (avPlayer) {
- [avPlayer release];
- }
}
@@ -461,7 +440,6 @@
NSNumber* msDate = [NSNumber numberWithDouble:[modDate timeIntervalSince1970]*1000];
[fileDict setObject:msDate forKey:@"lastModifiedDate"];
- [fileMgr release];
return fileDict;
}
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo
@@ -547,14 +525,6 @@
}
-- (void) dealloc
-{
- if (pickerController) {
- [pickerController release];
- }
- [super dealloc];
-}
-
@end
@implementation CDVAudioRecorderViewController
@@ -608,12 +578,12 @@
{
// create view and display
CGRect viewRect = [[UIScreen mainScreen] applicationFrame];
- UIView *tmp = [[[UIView alloc] initWithFrame:viewRect] autorelease];
+ UIView *tmp = [[UIView alloc] initWithFrame:viewRect];
// make backgrounds
UIImage* microphone = [UIImage imageNamed:[self resolveImageResource:@"Capture.bundle/microphone"]];
- UIView* microphoneView = [[[UIView alloc] initWithFrame: CGRectMake(0,0,viewRect.size.width, microphone.size.height)] autorelease];
+ UIView* microphoneView = [[UIView alloc] initWithFrame: CGRectMake(0,0,viewRect.size.width, microphone.size.height)];
[microphoneView setBackgroundColor:[UIColor colorWithPatternImage:microphone]];
[microphoneView setUserInteractionEnabled: NO];
[microphoneView setIsAccessibilityElement:NO];
@@ -621,7 +591,7 @@
// add bottom bar view
UIImage* grayBkg = [UIImage imageNamed: [self resolveImageResource:@"Capture.bundle/controls_bg"]];
- UIView* controls = [[[UIView alloc] initWithFrame:CGRectMake(0, microphone.size.height, viewRect.size.width,grayBkg.size.height )] autorelease];
+ UIView* controls = [[UIView alloc] initWithFrame:CGRectMake(0, microphone.size.height, viewRect.size.width,grayBkg.size.height )];
[controls setBackgroundColor:[UIColor colorWithPatternImage: grayBkg]];
[controls setUserInteractionEnabled: NO];
[controls setIsAccessibilityElement:NO];
@@ -630,7 +600,7 @@
// make red recording background view
UIImage* recordingBkg = [UIImage imageNamed: [self resolveImageResource:@"Capture.bundle/recording_bg"]];
UIColor *background = [UIColor colorWithPatternImage:recordingBkg];
- self.recordingView = [[[UIView alloc] initWithFrame: CGRectMake(0, 0, viewRect.size.width, recordingBkg.size.height)] autorelease];
+ self.recordingView = [[UIView alloc] initWithFrame: CGRectMake(0, 0, viewRect.size.width, recordingBkg.size.height)];
[self.recordingView setBackgroundColor:background];
[self.recordingView setHidden:YES];
[self.recordingView setUserInteractionEnabled: NO];
@@ -638,7 +608,7 @@
[tmp addSubview:self.recordingView];
// add label
- self.timerLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, viewRect.size.width,recordingBkg.size.height)] autorelease];
+ self.timerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, viewRect.size.width,recordingBkg.size.height)];
//timerLabel.autoresizingMask = reSizeMask;
[self.timerLabel setBackgroundColor:[UIColor clearColor]];
[self.timerLabel setTextColor:[UIColor whiteColor]];
@@ -654,14 +624,14 @@
self.recordImage = [UIImage imageNamed: [self resolveImageResource:@"Capture.bundle/record_button"]];
self.stopRecordImage = [UIImage imageNamed: [self resolveImageResource:@"Capture.bundle/stop_button"]];
self.recordButton.accessibilityTraits |= [self accessibilityTraits];
- self.recordButton = [[[UIButton alloc ] initWithFrame: CGRectMake((viewRect.size.width - recordImage.size.width)/2 , (microphone.size.height + (grayBkg.size.height - recordImage.size.height)/2), recordImage.size.width, recordImage.size.height)] autorelease];
+ self.recordButton = [[UIButton alloc ] initWithFrame: CGRectMake((viewRect.size.width - recordImage.size.width)/2 , (microphone.size.height + (grayBkg.size.height - recordImage.size.height)/2), recordImage.size.width, recordImage.size.height)];
[self.recordButton setAccessibilityLabel: NSLocalizedString(@"toggle audio recording", nil)];
[self.recordButton setImage: recordImage forState:UIControlStateNormal];
[self.recordButton addTarget: self action:@selector(processButton:) forControlEvents:UIControlEventTouchUpInside];
[tmp addSubview:recordButton];
// make and add done button to navigation bar
- self.doneButton = [[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissAudioView:)] autorelease];
+ self.doneButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissAudioView:)];
[self.doneButton setStyle:UIBarButtonItemStyleDone];
self.navigationItem.rightBarButtonItem = self.doneButton;
@@ -700,10 +670,9 @@
} while([fileMgr fileExistsAtPath: filePath]);
NSURL* fileURL = [NSURL fileURLWithPath:filePath isDirectory:NO];
- [fileMgr release];
// create AVAudioPlayer
- self.avRecorder = [[[AVAudioRecorder alloc] initWithURL:fileURL settings:nil error:&err] autorelease];
+ self.avRecorder = [[AVAudioRecorder alloc] initWithURL:fileURL settings:nil error:&err];
if (err) {
NSLog(@"Failed to initialize AVAudioRecorder: %@\n", [err localizedDescription]);
self.avRecorder = nil;
@@ -861,22 +830,4 @@
[self dismissAudioView: nil];
}
-- (void) dealloc
-{
- self.callbackId = nil;
- self.duration = nil;
- self.captureCommand = nil;
- self.doneButton = nil;
- self.recordingView = nil;
- self.recordButton = nil;
- self.recordImage = nil;
- self.stopRecordImage =nil;
- self.timerLabel = nil;
- self.avRecorder = nil;
- self.avSession = nil;
- self.resultString = nil;
- self.timer = nil;
-
- [super dealloc];
-}
@end
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVConnection.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVConnection.h b/CordovaLib/Classes/CDVConnection.h
index 05a9b69..334b614 100644
--- a/CordovaLib/Classes/CDVConnection.h
+++ b/CordovaLib/Classes/CDVConnection.h
@@ -29,6 +29,6 @@
}
@property (copy) NSString* connectionType;
-@property (retain) CDVReachability* internetReach;
+@property (strong) CDVReachability* internetReach;
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVConnection.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVConnection.m b/CordovaLib/Classes/CDVConnection.m
index 902fab2..afa9951 100644
--- a/CordovaLib/Classes/CDVConnection.m
+++ b/CordovaLib/Classes/CDVConnection.m
@@ -145,11 +145,9 @@
- (void)dealloc
{
- self.internetReach = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self
name:kReachabilityChangedNotification object:nil];
- [super dealloc];
}
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVContact.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContact.h b/CordovaLib/Classes/CDVContact.h
index 63c7fbb..a9a1a08 100644
--- a/CordovaLib/Classes/CDVContact.h
+++ b/CordovaLib/Classes/CDVContact.h
@@ -41,15 +41,13 @@ typedef NSUInteger CDVContactError;
}
@property (nonatomic, assign) ABRecordRef record;
-@property (nonatomic, retain) NSDictionary* returnFields;
+@property (nonatomic, strong) NSDictionary* returnFields;
+(NSDictionary*) defaultABtoW3C;
+(NSDictionary*) defaultW3CtoAB;
+(NSSet*) defaultW3CtoNull;
+(NSDictionary*) defaultObjectAndProperties;
+(NSDictionary*) defaultFields;
-+(void) releaseDefaults;
-
+(NSDictionary*) calcReturnFields: (NSArray*)fields;
-(id)init;
@@ -85,9 +83,6 @@ typedef NSUInteger CDVContactError;
- (NSArray *) labelsForProperty: (ABPropertyID) propId inRecord: (ABRecordRef)aRecord;
-(BOOL) searchContactFields: (NSArray*) fields forMVDictionaryProperty: (ABPropertyID) propId withValue: (NSString*)testValue;
-- (void) dealloc;
-
-
@end
// generic ContactField types
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVContact.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContact.m b/CordovaLib/Classes/CDVContact.m
index 73f4b73..2730cee 100644
--- a/CordovaLib/Classes/CDVContact.m
+++ b/CordovaLib/Classes/CDVContact.m
@@ -107,8 +107,6 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
kW3ContactUrls,[NSNumber numberWithInt: kABPersonURLProperty],
kW3ContactNote, [NSNumber numberWithInt: kABPersonNoteProperty],
nil];
- // these dictionaries get invalidated without the retain, although running with GuardMalloc shows no memory overwrites???
- [org_apache_cordova_contacts_ABtoW3C retain];
}
return org_apache_cordova_contacts_ABtoW3C;
@@ -146,7 +144,6 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
[NSNull null], kW3ContactFieldId,
[NSNumber numberWithInt: kABPersonOrganizationProperty], kW3ContactOrganizationName, /* careful, name is used mulitple times*/
nil];
- [org_apache_cordova_contacts_W3CtoAB retain];
}
return org_apache_cordova_contacts_W3CtoAB;
}
@@ -157,7 +154,6 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
if (org_apache_cordova_contacts_W3CtoNull == nil){
org_apache_cordova_contacts_W3CtoNull = [NSSet setWithObjects: kW3ContactDisplayName,
kW3ContactCategories, kW3ContactFormattedName, nil];
- [org_apache_cordova_contacts_W3CtoNull retain];
}
return org_apache_cordova_contacts_W3CtoNull;
}
@@ -180,7 +176,6 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
[NSArray arrayWithObjects:kW3ContactFieldType, kW3ContactFieldValue, kW3ContactFieldPrimary,nil], kW3ContactUrls,
[NSArray arrayWithObjects: kW3ContactImValue, kW3ContactImType, nil], kW3ContactIms,
nil];
- [org_apache_cordova_contacts_objectAndProperties retain];
}
return org_apache_cordova_contacts_objectAndProperties;
}
@@ -200,36 +195,9 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
[NSNull null],kW3ContactBirthday,
[NSNull null],kW3ContactNote,
nil];
- [org_apache_cordova_contacts_defaultFields retain];
-
}
return org_apache_cordova_contacts_defaultFields;
}
-
-+(void) releaseDefaults
-{
- // ugly but it works
- if (org_apache_cordova_contacts_ABtoW3C != nil) {
- [org_apache_cordova_contacts_ABtoW3C release];
- org_apache_cordova_contacts_ABtoW3C = nil;
- }
- if (org_apache_cordova_contacts_W3CtoAB != nil) {
- [org_apache_cordova_contacts_W3CtoAB release];
- org_apache_cordova_contacts_W3CtoAB = nil;
- }
- if (org_apache_cordova_contacts_W3CtoNull != nil) {
- [org_apache_cordova_contacts_W3CtoNull release];
- org_apache_cordova_contacts_W3CtoNull = nil;
- }
- if (org_apache_cordova_contacts_objectAndProperties != nil) {
- [org_apache_cordova_contacts_objectAndProperties release];
- org_apache_cordova_contacts_objectAndProperties = nil;
- }
- if (org_apache_cordova_contacts_defaultFields != nil) {
- [org_apache_cordova_contacts_defaultFields release];
- org_apache_cordova_contacts_defaultFields = nil;
- }
-}
/* Translate W3C Contact data into ABRecordRef
*
@@ -388,7 +356,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
data = [NSData dataWithContentsOfURL:photoUrl options: NSDataReadingUncached error:&err];
}
if(data && [data length] > 0){
- bSuccess = ABPersonSetImageData(person, (CFDataRef)data, &error);
+ bSuccess = ABPersonSetImageData(person, (__bridge CFDataRef)data, &error);
}
if (!data || !bSuccess){
NSLog(@"error setting contact image: %@", (err != nil ? [err localizedDescription] : @""));
@@ -426,7 +394,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
if (bUpdate && ([aValue isKindOfClass:[NSString class]] && [aValue length] == 0)) { // if updating, empty string means to delete
aValue = NULL;
} // really only need to set if different - more efficient to just update value or compare and only set if necessay???
- bSuccess = ABRecordSetValue(aRecord, aProperty, aValue, &error);
+ bSuccess = ABRecordSetValue(aRecord, aProperty, (__bridge CFTypeRef) aValue, &error);
if (!bSuccess){
NSLog(@"error setting %d property", aProperty);
}
@@ -450,8 +418,8 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
bool bSuccess = FALSE;
id value = [dict valueForKey:kW3ContactFieldValue];
if (IS_VALID_VALUE(value)){
- NSString* label = (NSString*)[CDVContact convertContactTypeToPropertyLabel:[dict valueForKey:kW3ContactFieldType]];
- bSuccess = ABMultiValueAddValueAndLabel(multi, value,(CFStringRef)label, NULL);
+ CFStringRef label = [CDVContact convertContactTypeToPropertyLabel:[dict valueForKey:kW3ContactFieldType]];
+ bSuccess = ABMultiValueAddValueAndLabel(multi, (__bridge CFTypeRef)value,label, NULL);
if (!bSuccess) {
NSLog(@"Error setting Value: %@ and label: %@", value, label);
}
@@ -512,7 +480,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
id val;
NSString* label = nil;
val = [dict valueForKey:kW3ContactFieldValue];
- label = (NSString*)[CDVContact convertContactTypeToPropertyLabel:[dict valueForKey:kW3ContactFieldType]];
+ label = (__bridge NSString*)[CDVContact convertContactTypeToPropertyLabel:[dict valueForKey:kW3ContactFieldType]];
if (IS_VALID_VALUE(val)){
// is an update, find index of entry with matching id, if values are different, update.
id idValue = [dict valueForKey: kW3ContactFieldId];
@@ -523,13 +491,13 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
// remove both value and label
ABMultiValueRemoveValueAndLabelAtIndex(multi, i);
} else {
- NSString* valueAB = [(NSString*)ABMultiValueCopyValueAtIndex(multi, i) autorelease];
- NSString* labelAB = [(NSString*)ABMultiValueCopyLabelAtIndex(multi, i) autorelease];
+ NSString* valueAB = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(multi, i);
+ NSString* labelAB = (__bridge_transfer NSString*)ABMultiValueCopyLabelAtIndex(multi, i);
if (valueAB == nil || ![val isEqualToString: valueAB]){
- ABMultiValueReplaceValueAtIndex(multi, val, i);
+ ABMultiValueReplaceValueAtIndex(multi, (__bridge CFTypeRef)val, i);
}
if (labelAB == nil || ![label isEqualToString:labelAB]){
- ABMultiValueReplaceLabelAtIndex(multi, (CFStringRef)label, i);
+ ABMultiValueReplaceLabelAtIndex(multi, (__bridge CFStringRef)label, i);
}
}
} else {
@@ -655,8 +623,9 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
BOOL bUpdateLabel = NO;
if (idx != kCFNotFound){
dict = [NSMutableDictionary dictionaryWithCapacity:1];
- NSDictionary* existingDictionary = (NSDictionary*)ABMultiValueCopyValueAtIndex(multi, idx);
- NSString* existingABLabel = [(NSString*)ABMultiValueCopyLabelAtIndex(multi, idx) autorelease];
+ //NSDictionary* existingDictionary = (NSDictionary*)ABMultiValueCopyValueAtIndex(multi, idx);
+ CFTypeRef existingDictionary = ABMultiValueCopyValueAtIndex(multi, idx);
+ NSString* existingABLabel = (__bridge_transfer NSString*)ABMultiValueCopyLabelAtIndex(multi, idx);
NSString* testLabel = [field valueForKey:kW3ContactFieldType];
// fixes cb-143 where setting empty label could cause address to not be removed
// (because empty label would become 'other' in convertContactTypeToPropertyLabel
@@ -665,7 +634,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
if (testLabel && [testLabel isKindOfClass:[NSString class]] && [testLabel length] > 0)
{
CFStringRef w3cLabel = [CDVContact convertContactTypeToPropertyLabel:testLabel];
- if (w3cLabel && ![existingABLabel isEqualToString:(NSString*)w3cLabel]){
+ if (w3cLabel && ![existingABLabel isEqualToString:(__bridge NSString*)w3cLabel]){
//replace the label
ABMultiValueReplaceLabelAtIndex(multi, w3cLabel,idx);
bUpdateLabel = YES;
@@ -681,7 +650,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
[dict setObject:setValue forKey: (NSString*)[[CDVContact defaultW3CtoAB] valueForKey:(NSString*)k]];
} else if (value == nil || ([value isKindOfClass:[NSString class]] && [value length] != 0)) {
// value not provided in contact dictionary - if prop exists in AB dictionary, preserve it
- valueAB = [existingDictionary valueForKey:[[CDVContact defaultW3CtoAB] valueForKey:k]];
+ valueAB = [(__bridge NSDictionary*)existingDictionary valueForKey:[[CDVContact defaultW3CtoAB] valueForKey:k]];
if (valueAB != nil){
[dict setValue:valueAB forKey:[[CDVContact defaultW3CtoAB] valueForKey:k]];
}
@@ -689,7 +658,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
} // end of for loop (moving here fixes cb-143, need to end for loop before replacing or removing multivalue)
if ([dict count] > 0){
// something was added into new dict,
- ABMultiValueReplaceValueAtIndex(multi, dict, idx);
+ ABMultiValueReplaceValueAtIndex(multi, (__bridge CFTypeRef)dict, idx);
} else if (!bUpdateLabel) {
// nothing added into new dict and no label change so remove this property entry
ABMultiValueRemoveValueAndLabelAtIndex(multi, idx);
@@ -907,7 +876,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
}
// nickname
if ([self.returnFields valueForKey:kW3ContactNickname]){
- value = [(NSString*)ABRecordCopyValue(self.record, kABPersonNicknameProperty) autorelease];
+ value = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, kABPersonNicknameProperty);
[nc setObject: (value != nil) ? value : [NSNull null] forKey:kW3ContactNickname];
}
@@ -920,12 +889,12 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
if ([self.returnFields objectForKey:kW3ContactDisplayName] && (data == nil || [(NSDictionary*)data objectForKey: kW3ContactFormattedName] == [NSNull null])){
// user asked for displayName which iOS doesn't support but there is no other name data being returned
// try and use Composite Name so some name is returned
- id tryName = [(NSString*)ABRecordCopyCompositeName(self.record) autorelease];
+ id tryName = (__bridge_transfer NSString*)ABRecordCopyCompositeName(self.record);
if (tryName != nil){
[nc setObject:tryName forKey:kW3ContactDisplayName];
} else {
// use nickname or empty string
- value = [(NSString*)ABRecordCopyValue(self.record, kABPersonNicknameProperty) autorelease];
+ value = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, kABPersonNicknameProperty);
[nc setObject:(value!= nil) ? value : @"" forKey:kW3ContactDisplayName];
}
}
@@ -950,7 +919,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
//NSLog(@"getting addresses");
value = [self extractAddresses];
if (value != nil){
- [nc setObject:[self extractAddresses] forKey: kW3ContactAddresses];
+ [nc setObject:value forKey: kW3ContactAddresses];
}
// im array
//NSLog(@"getting ims");
@@ -1019,7 +988,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
if ([self.returnFields valueForKey:kW3ContactNote]){
// note
- value = [(NSString*)ABRecordCopyValue(self.record, kABPersonNoteProperty) autorelease];
+ value = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, kABPersonNoteProperty);
[nc setObject: (value != nil) ? value : [NSNull null] forKey:kW3ContactNote];
}
@@ -1052,7 +1021,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
NSDate* aDate = nil;
CFTypeRef cfDate = ABRecordCopyValue(self.record, datePropId);
if (cfDate) {
- aDate = (NSDate*) cfDate;
+ aDate = (__bridge NSDate*) cfDate;
msDate = [NSNumber numberWithDouble:([aDate timeIntervalSince1970]*1000)];
CFRelease(cfDate);
}
@@ -1080,11 +1049,11 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
id value;
for (NSString* i in fields){
if ([i isEqualToString:kW3ContactFormattedName]){
- value = [(NSString*)ABRecordCopyCompositeName(self.record) autorelease];
+ value = (__bridge_transfer NSString*)ABRecordCopyCompositeName(self.record);
[newName setObject: (value != nil) ? value : [NSNull null] forKey: kW3ContactFormattedName];
}else {
//W3CtoAB returns NSNumber for AB name properies, get intValue and cast to ABPropertyID)
- value = [(NSString*)ABRecordCopyValue(self.record, (ABPropertyID)[[[CDVContact defaultW3CtoAB] valueForKey:i] intValue]) autorelease];
+ value = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, (ABPropertyID)[[[CDVContact defaultW3CtoAB] valueForKey:i] intValue]);
[newName setObject: (value != nil) ? value : [NSNull null] forKey: (NSString*)i];
}
}
@@ -1121,12 +1090,12 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
for (CFIndex i=0; i<count; i++) {
NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity:4];
if ([fields containsObject:kW3ContactFieldType]){
- NSString* label = [(NSString*)ABMultiValueCopyLabelAtIndex(multi, i) autorelease];
+ NSString* label = (__bridge_transfer NSString*)ABMultiValueCopyLabelAtIndex(multi, i);
value = [CDVContact convertPropertyLabelToContactType: label];
[newDict setObject: (value != nil) ? value : [NSNull null] forKey: kW3ContactFieldType];
}
if ([fields containsObject:kW3ContactFieldValue]){
- value = [(NSString*)ABMultiValueCopyValueAtIndex(multi, i) autorelease];
+ value = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(multi, i);
[newDict setObject: (value != nil) ? value : [NSNull null] forKey: kW3ContactFieldValue];
}
if ([fields containsObject:kW3ContactFieldPrimary]){
@@ -1167,7 +1136,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
if (fields == nil) { // no name fields requested
return nil;
}
- id value;
+ id __unsafe_unretained value;
NSObject* addresses;
ABMultiValueRef multi = ABRecordCopyValue(self.record, kABPersonAddressProperty);
CFIndex count = multi ? ABMultiValueGetCount(multi) : 0;
@@ -1181,7 +1150,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
id identifier = [NSNumber numberWithUnsignedInt: ABMultiValueGetIdentifierAtIndex(multi,i)];
[newAddress setObject: (identifier !=nil) ? identifier : [NSNull null] forKey:kW3ContactFieldId];
// set the type label
- NSString* label = [(NSString*)ABMultiValueCopyLabelAtIndex(multi, i) autorelease];
+ NSString* label = (__bridge_transfer NSString*)ABMultiValueCopyLabelAtIndex(multi, i);
[newAddress setObject: (label != nil) ? (NSObject*) [[CDVContact class] convertPropertyLabelToContactType:label] : [NSNull null] forKey:kW3ContactFieldType];
// set the pref - iOS doesn't support so set to default of false
@@ -1192,7 +1161,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
bool bFound;
id key = [[CDVContact defaultW3CtoAB] valueForKey:k];
if (key && ![k isKindOfClass:[NSNull class]]){
- bFound = CFDictionaryGetValueIfPresent(dict, key, (void *)&value);
+ bFound = CFDictionaryGetValueIfPresent(dict, (__bridge const void*)key, (void *)&value);
[newAddress setObject: (bFound && value != NULL) ? (id)value : [NSNull null] forKey: k];
} else {
// was a property that iPhone doesn't support
@@ -1200,7 +1169,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
}
}
- if ([newAddress count] > 0){
+ if ([newAddress count] > 0){ //?? this will always be true since we set id,label,primary field??
[(NSMutableArray*)addresses addObject:newAddress];
}
CFRelease(dict);
@@ -1240,7 +1209,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* value; // all values should be CFStringRefs / NSString*
+ NSString* __unsafe_unretained value; // all values should be CFStringRefs / NSString*
bool bFound;
if ([fields containsObject: kW3ContactFieldValue]){
// value = user name
@@ -1288,7 +1257,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
for (id i in fields){
id key = [[CDVContact defaultW3CtoAB] valueForKey:i];
if (key && [key isKindOfClass:[NSNumber class]]){
- value = [(NSString *)ABRecordCopyValue(self.record, (ABPropertyID)[[[CDVContact defaultW3CtoAB] valueForKey:i] intValue]) autorelease];
+ value = (__bridge_transfer NSString *)ABRecordCopyValue(self.record, (ABPropertyID)[[[CDVContact defaultW3CtoAB] valueForKey:i] intValue]);
if (value != nil) {
// if there are no organization values we should return null for organization
// this counter keeps indicates if any organization values have been set
@@ -1321,7 +1290,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
NSMutableArray* photos = nil;
if (ABPersonHasImageData(self.record)){
CFDataRef photoData = ABPersonCopyImageData(self.record);
- NSData* data = (NSData*)photoData;
+ NSData* data = (__bridge NSData*)photoData;
// write to temp directory and store URI in photos array
// get the temp directory path
NSString* docsPath = [NSTemporaryDirectory() stringByStandardizingPath];
@@ -1342,7 +1311,6 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
[newDict setObject:@"false" forKey:kW3ContactFieldPrimary];
[photos addObject:newDict];
}
- [fileMgr release];
CFRelease(photoData);
}
@@ -1470,7 +1438,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
NSArray* fields = [searchFields valueForKey:kW3ContactName];
for (NSString* testItem in fields){
if ([testItem isEqualToString:kW3ContactFormattedName]){
- NSString* propValue = [(NSString*)ABRecordCopyCompositeName(self.record) autorelease];
+ NSString* propValue = (__bridge_transfer NSString*)ABRecordCopyCompositeName(self.record);
if (propValue != nil && [propValue length] > 0) {
NSRange range = [propValue rangeOfString:testValue options: NSCaseInsensitiveSearch];
bFound = (range.location != NSNotFound);
@@ -1548,7 +1516,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
if ([[CDVContact defaultW3CtoAB] valueForKeyIsNumber: property ]) {
ABPropertyID propId = [[[CDVContact defaultW3CtoAB] objectForKey: property] intValue];
if(ABPersonGetTypeOfProperty(propId) == kABStringPropertyType){
- NSString* propValue = [(NSString*)ABRecordCopyValue(self.record, propId) autorelease];
+ NSString* propValue = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, propId);
if (propValue != nil && [propValue length] > 0) {
NSPredicate *containPred = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@", testValue];
bFound = [containPred evaluateWithObject:propValue];
@@ -1575,7 +1543,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
if ([[CDVContact defaultW3CtoAB] valueForKeyIsNumber: property ]) {
ABPropertyID propId = [[[CDVContact defaultW3CtoAB] objectForKey: property] intValue];
if(ABPersonGetTypeOfProperty(propId) == kABDateTimePropertyType){
- NSDate* date = [(NSDate*)ABRecordCopyValue(self.record, propId) autorelease];
+ NSDate* date = (__bridge_transfer NSDate*)ABRecordCopyValue(self.record, propId);
if (date != nil) {
NSString* dateString = [date descriptionWithLocale:[NSLocale currentLocale]];
NSPredicate *containPred = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@", testValue];
@@ -1653,12 +1621,12 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
/*
* Returns the array of values for a multivalue string property of the specified property id
*/
-- (NSArray *) valuesForProperty: (ABPropertyID) propId inRecord: (ABRecordRef) aRecord
+- (__autoreleasing NSArray *) valuesForProperty: (ABPropertyID) propId inRecord: (ABRecordRef) aRecord
{
ABMultiValueRef multi = ABRecordCopyValue(aRecord, propId);
- NSArray *values = (NSArray *)ABMultiValueCopyArrayOfAllValues(multi);
+ NSArray *values = (__bridge_transfer NSArray *)ABMultiValueCopyArrayOfAllValues(multi);
CFRelease(multi);
- return [values autorelease];
+ return values;
}
/*
* Returns the array of labels for a multivalue string property of the specified property id
@@ -1669,10 +1637,9 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
CFIndex count = ABMultiValueGetCount(multi);
NSMutableArray *labels = [NSMutableArray arrayWithCapacity:count];
for (int i = 0; i < count; i++) {
- NSString *label = (NSString *)ABMultiValueCopyLabelAtIndex(multi, i);
+ NSString *label = (__bridge_transfer NSString *)ABMultiValueCopyLabelAtIndex(multi, i);
if (label){
[labels addObject:label];
- [label release];
}
}
CFRelease(multi);
@@ -1689,13 +1656,15 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
{
BOOL bFound = NO;
- NSArray* values = [self valuesForProperty:propId inRecord:self.record]; // array of dictionaries (as CFDictionaryRef)
+ NSArray* values = [self valuesForProperty:propId inRecord:self.record]; // array of dictionaries (as CFDictionaryRef)
+ int dictCount = [values count];
// for ims dictionary contains with service (w3C type) and username (W3c value)
// for addresses dictionary contains street, city, state, zip, country
- for(id dict in values){
+ for(int i=0; i<dictCount; i++) {
+ CFDictionaryRef dict = (__bridge CFDictionaryRef)[values objectAtIndex:i];
for(NSString* member in fields){
NSString* abKey = [[CDVContact defaultW3CtoAB] valueForKey:member]; // im and address fields are all strings
- NSString* abValue = nil;
+ NSString* __unsafe_unretained abValue = nil;
if (abKey){
NSString* testString = nil;
if ([member isEqualToString:kW3ContactImType]){
@@ -1707,7 +1676,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
testString = testValue;
}
if(testString != nil){
- BOOL bExists = CFDictionaryGetValueIfPresent((CFDictionaryRef)dict, abKey, (void *)&abValue);
+ BOOL bExists = CFDictionaryGetValueIfPresent(dict, (__bridge const void*)abKey, (void *)&abValue);
if(bExists) {
NSPredicate *containPred = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@", testString];
bFound = [containPred evaluateWithObject:abValue];
@@ -1725,14 +1694,4 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
return bFound;
}
-
-- (void) dealloc
-{
- if (record != NULL){
- CFRelease(record);
- }
- self.returnFields = nil;
-
- [super dealloc];
-}
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVContacts.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContacts.h b/CordovaLib/Classes/CDVContacts.h
index 90960b6..f494778 100755
--- a/CordovaLib/Classes/CDVContacts.h
+++ b/CordovaLib/Classes/CDVContacts.h
@@ -99,7 +99,7 @@
*/
- (void) remove: (NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-- (void) dealloc;
+//- (void) dealloc;
@end
@@ -132,7 +132,7 @@
{
}
-@property (nonatomic,retain) CDVPlugin* contactsPlugin;
+@property (nonatomic,strong) CDVPlugin* contactsPlugin;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVContacts.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContacts.m b/CordovaLib/Classes/CDVContacts.m
index 2098c71..a47e6f4 100755
--- a/CordovaLib/Classes/CDVContacts.m
+++ b/CordovaLib/Classes/CDVContacts.m
@@ -66,7 +66,6 @@
-(void)onAppTerminate
{
//NSLog(@"Contacts::onAppTerminate");
- [CDVContact releaseDefaults];
}
@@ -75,7 +74,7 @@
{
NSString* callbackId = [arguments objectAtIndex:0];
- CDVNewContactsController* npController = [[[CDVNewContactsController alloc] init] autorelease];
+ CDVNewContactsController* npController = [[CDVNewContactsController alloc] init];
ABAddressBookRef ab = ABAddressBookCreate();
npController.addressBook = ab; // a CF retaining assign
@@ -84,7 +83,7 @@
npController.newPersonViewDelegate = self;
npController.callbackId = callbackId;
- UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:npController] autorelease];
+ UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:npController];
if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
[self.viewController presentViewController:navController animated:YES completion:nil];
@@ -130,14 +129,14 @@
ABAddressBookRef addrBook = ABAddressBookCreate();
ABRecordRef rec = ABAddressBookGetPersonWithRecordID(addrBook, recordID);
if (rec) {
- CDVDisplayContactViewController* personController = [[[CDVDisplayContactViewController alloc] init] autorelease];
+ CDVDisplayContactViewController* personController = [[CDVDisplayContactViewController alloc] init];
personController.displayedPerson = rec;
personController.personViewDelegate = self;
personController.allowsEditing = NO;
// create this so DisplayContactViewController will have a "back" button.
- UIViewController* parentController = [[[UIViewController alloc] init] autorelease];
- UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:parentController] autorelease];
+ UIViewController* parentController = [[UIViewController alloc] init];
+ UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:parentController];
[navController pushViewController:personController animated:YES];
@@ -149,7 +148,7 @@
if (bEdit) {
// create the editing controller and push it onto the stack
- ABPersonViewController* editPersonController = [[[ABPersonViewController alloc] init] autorelease];
+ ABPersonViewController* editPersonController = [[ABPersonViewController alloc] init];
editPersonController.displayedPerson = rec;
editPersonController.personViewDelegate = self;
editPersonController.allowsEditing = YES;
@@ -176,7 +175,7 @@
{
NSString* callbackId = [arguments objectAtIndex:0];
- CDVContactsPicker* pickerController = [[[CDVContactsPicker alloc] init] autorelease];
+ CDVContactsPicker* pickerController = [[CDVContactsPicker alloc] init];
pickerController.peoplePickerDelegate = self;
pickerController.callbackId = callbackId;
pickerController.selectedId = kABRecordInvalidID;
@@ -200,7 +199,7 @@
if (picker.allowsEditing) {
- ABPersonViewController* personController = [[[ABPersonViewController alloc] init] autorelease];
+ ABPersonViewController* personController = [[ABPersonViewController alloc] init];
personController.displayedPerson = person;
personController.personViewDelegate = self;
personController.allowsEditing = picker.allowsEditing;
@@ -273,26 +272,26 @@
NSMutableArray* matches = nil;
if (!filter || [filter isEqualToString:@""]){
// get all records
- foundRecords = (NSArray*)ABAddressBookCopyArrayOfAllPeople(addrBook);
+ foundRecords = (__bridge_transfer NSArray*)ABAddressBookCopyArrayOfAllPeople(addrBook);
if (foundRecords && [foundRecords count] > 0){
// create Contacts and put into matches array
// doesn't make sense to ask for all records when multiple == NO but better check
int xferCount = multiple == YES ? [foundRecords count] : 1;
matches = [NSMutableArray arrayWithCapacity:xferCount];
for(int k = 0; k<xferCount; k++){
- CDVContact* xferContact = [[[CDVContact alloc] initFromABRecord:(ABRecordRef)[foundRecords objectAtIndex:k]] autorelease];
+ CDVContact* xferContact = [[CDVContact alloc] initFromABRecord:(ABRecordRef)[foundRecords objectAtIndex:k]];
[matches addObject:xferContact];
xferContact = nil;
}
}
} else {
- foundRecords = (NSArray*)ABAddressBookCopyArrayOfAllPeople(addrBook);
+ foundRecords = (__bridge_transfer NSArray*)ABAddressBookCopyArrayOfAllPeople(addrBook);
matches = [NSMutableArray arrayWithCapacity:1];
BOOL bFound = NO;
int testCount = [foundRecords count];
for(int j=0; j<testCount; j++){
- CDVContact* testContact = [[[CDVContact alloc] initFromABRecord: (ABRecordRef)[foundRecords objectAtIndex:j]] autorelease];
+ CDVContact* testContact = [[CDVContact alloc] initFromABRecord: (ABRecordRef)[foundRecords objectAtIndex:j]];
if (testContact){
bFound = [testContact foundValue:filter inFields:returnFields];
if(bFound){
@@ -308,28 +307,25 @@
if (matches != nil && [matches count] > 0){
// convert to JS Contacts format and return in callback
// - returnFields determines what properties to return
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- int count = multiple == YES ? [matches count] : 1;
- for(int i = 0; i<count; i++){
- CDVContact* newContact = [matches objectAtIndex:i];
- NSDictionary* aContact = [newContact toDictionary: returnFields];
- [returnContacts addObject:aContact];
+ @autoreleasepool {
+ int count = multiple == YES ? [matches count] : 1;
+ for(int i = 0; i<count; i++){
+ CDVContact* newContact = [matches objectAtIndex:i];
+ NSDictionary* aContact = [newContact toDictionary: returnFields];
+ [returnContacts addObject:aContact];
+ }
}
- [pool release];
}
CDVPluginResult* result = nil;
// return found contacts (array is empty if no contacts found)
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray: returnContacts];
jsString = [result toSuccessCallbackString:callbackId];
- // NSLog(@"findCallback string: %@", jsString);
+ //NSLog(@"findCallback string: %@", jsString);
if(addrBook){
CFRelease(addrBook);
}
- if (foundRecords){
- [foundRecords release];
- }
if(jsString){
[self writeJavascript:jsString];
@@ -390,7 +386,6 @@
bIsError = TRUE;
errCode = IO_ERROR;
}
- [aContact release];
CFRelease(addrBook);
if (bIsError){
@@ -469,17 +464,6 @@
}
-- (void)dealloc
-{
- /*ABAddressBookUnregisterExternalChangeCallback(addressBook, addressBookChanged, self);
-
- if (addressBook) {
- CFRelease(addressBook);
- }
- */
-
- [super dealloc];
-}
@end
@@ -502,11 +486,6 @@
}
}
--(void) dealloc
-{
- self.contactsPlugin=nil;
- [super dealloc];
-}
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVCordovaView.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCordovaView.h b/CordovaLib/Classes/CDVCordovaView.h
index 32a2b1a..53e9f01 100644
--- a/CordovaLib/Classes/CDVCordovaView.h
+++ b/CordovaLib/Classes/CDVCordovaView.h
@@ -24,6 +24,4 @@
}
-
-
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVCordovaView.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCordovaView.m b/CordovaLib/Classes/CDVCordovaView.m
index 4448bdb..426ece1 100644
--- a/CordovaLib/Classes/CDVCordovaView.m
+++ b/CordovaLib/Classes/CDVCordovaView.m
@@ -39,9 +39,6 @@
-- (void)dealloc {
- [super dealloc];
-}
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVDevice.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVDevice.m b/CordovaLib/Classes/CDVDevice.m
index b076a0a..dcaec6a 100644
--- a/CordovaLib/Classes/CDVDevice.m
+++ b/CordovaLib/Classes/CDVDevice.m
@@ -50,9 +50,7 @@
if (jsResult != nil && [jsResult length] > 0) {
NSLog(@"%@", jsResult);
}
-
- [result release];
-
+
[self success:pluginResult callbackId:cbId];
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVFile.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFile.h b/CordovaLib/Classes/CDVFile.h
index 6e2fec7..f872db1 100644
--- a/CordovaLib/Classes/CDVFile.h
+++ b/CordovaLib/Classes/CDVFile.h
@@ -101,11 +101,11 @@ typedef int CDVFileSystemType;
- (unsigned long long) truncateFile:(NSString*)filePath atPosition:(unsigned long long)pos;
-@property (nonatomic, retain)NSString *appDocsPath;
-@property (nonatomic, retain)NSString *appLibraryPath;
-@property (nonatomic, retain)NSString *appTempPath;
-@property (nonatomic, retain)NSString *persistentPath;
-@property (nonatomic, retain)NSString *temporaryPath;
+@property (nonatomic, strong)NSString *appDocsPath;
+@property (nonatomic, strong)NSString *appLibraryPath;
+@property (nonatomic, strong)NSString *appTempPath;
+@property (nonatomic, strong)NSString *persistentPath;
+@property (nonatomic, strong)NSString *temporaryPath;
@property BOOL userHasAllowed;
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVFile.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFile.m b/CordovaLib/Classes/CDVFile.m
index a6092bd..154c960 100644
--- a/CordovaLib/Classes/CDVFile.m
+++ b/CordovaLib/Classes/CDVFile.m
@@ -63,11 +63,10 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
{
NSFileManager* fMgr = [[NSFileManager alloc] init];
- NSError* pError = nil;
+ NSError* __autoreleasing pError = nil;
NSDictionary* pDict = [ fMgr attributesOfFileSystemForPath:appPath error:&pError ];
NSNumber* pNumAvail = (NSNumber*)[ pDict objectForKey:NSFileSystemFreeSize ];
- [fMgr release];
return pNumAvail;
}
@@ -278,8 +277,6 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
jsString = [result toErrorCallbackString:callbackId];
}
-
- [fileMgr release];
}
if (jsString != nil){
[self writeJavascript:jsString];
@@ -389,7 +386,7 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
// if bExists and create == NO - just return data
// if !bExists and create == YES - create and return data
BOOL bSuccess = YES;
- NSError* pError = nil;
+ NSError __autoreleasing *pError = nil;
if(!bExists && create == YES){
if(bDirRequest) {
// create the dir
@@ -411,7 +408,6 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
jsString = [result toSuccessCallbackString: callbackId];
}
} // are all possible conditions met?
- [fileMgr release];
}
@@ -466,7 +462,6 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: [self getDirectoryEntry:newPath isDirectory:bIsDir]];
jsString = [result toSuccessCallbackString:callbackId];
}
- [fileMgr release];
}
if (!jsString) {
// invalid path or file does not exist
@@ -489,7 +484,7 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
NSString* testPath = argPath; //[self getFullPath: argPath];
NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSError* error = nil;
+ NSError* __autoreleasing error = nil;
CDVPluginResult* result = nil;
NSString* jsString = nil;
@@ -515,7 +510,6 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
if (jsString){
[self writeJavascript:jsString];
}
- [fileMgr release];
}
/*
@@ -541,7 +535,7 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
if (IsAtLeastiOSVersion(@"5.1"))
{
NSURL* url = [NSURL fileURLWithPath:filePath];
- NSError* error = nil;
+ NSError* __autoreleasing error = nil;
ok = [url setResourceValue: [NSNumber numberWithBool: [iCloudBackupExtendedAttributeValue boolValue]] forKey: NSURLIsExcludedFromBackupKey error:&error];
}
@@ -603,7 +597,6 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
// dir is not empty
errorCode = INVALID_MODIFICATION_ERR;
}
- [fileMgr release];
}
if (errorCode > 0) {
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt: errorCode];
@@ -659,7 +652,7 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
CDVPluginResult* result = nil;
NSString* jsString = nil;
BOOL bSuccess = NO;
- NSError* pError = nil;
+ NSError* __autoreleasing pError = nil;
NSFileManager* fileMgr = [[ NSFileManager alloc] init];
@try {
@@ -685,7 +678,6 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
jsString = [result toErrorCallbackString:callbackId];
}
@finally {
- [fileMgr release];
return jsString;
}
}
@@ -783,7 +775,7 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
// can't copy/move dir to file
errCode = INVALID_MODIFICATION_ERR;
} else { // no errors yet
- NSError* error = nil;
+ NSError* __autoreleasing error = nil;
BOOL bSuccess = NO;
if (bCopy){
if (bSrcIsDir && ![self canCopyMoveSrc: srcFullPath ToDestination: newFullPath]/*[newFullPath hasPrefix:srcFullPath]*/) {
@@ -847,7 +839,6 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
}
}
}
- [fileMgr release];
}
}
if (errCode > 0) {
@@ -916,7 +907,7 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
jsString = [result toErrorCallbackString:callbackId];
} else {
// create dictionary of file info
- NSError* error = nil;
+ NSError* __autoreleasing error = nil;
NSDictionary* fileAttrs = [fileMgr attributesOfItemAtPath:fullPath error:&error];
NSMutableDictionary* fileInfo = [NSMutableDictionary dictionaryWithCapacity:5];
[fileInfo setObject: [NSNumber numberWithUnsignedLongLong:[fileAttrs fileSize]] forKey:@"size"];
@@ -929,7 +920,6 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: fileInfo];
jsString = [result toSuccessCallbackString:callbackId];
}
- [fileMgr release];
}
[self writeJavascript:jsString];
@@ -946,7 +936,7 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
NSString* jsString = nil;
NSFileManager* fileMgr = [[ NSFileManager alloc] init];
- NSError* error = nil;
+ NSError* __autoreleasing error = nil;
NSArray* contents = [fileMgr contentsOfDirectoryAtPath:fullPath error: &error];
if (contents) {
NSMutableArray* entries = [NSMutableArray arrayWithCapacity:1];
@@ -967,10 +957,8 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
// assume not found but could check error for more specific error conditions
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt: NOT_FOUND_ERR];
jsString = [result toErrorCallbackString:callbackId];
- }
+ }
- [fileMgr release];
-
[self writeJavascript: jsString];
}
@@ -1022,9 +1010,6 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString: [ pNStrBuff stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ];
jsString = [result toSuccessCallbackString:callbackId];
- [ pNStrBuff release ];
-
-
}
if (jsString){
[self writeJavascript: jsString];
@@ -1094,15 +1079,12 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
NSString* mimeType = nil;
if(fullPath) {
- CFStringRef typeId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension,(CFStringRef)[fullPath pathExtension], NULL);
+ CFStringRef typeId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension,(__bridge CFStringRef)[fullPath pathExtension], NULL);
if (typeId) {
- mimeType = (NSString*)UTTypeCopyPreferredTagWithClass(typeId,kUTTagClassMIMEType);
- if (mimeType) {
- [mimeType autorelease];
- //NSLog(@"mime type: %@", mimeType);
- } else {
+ mimeType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass(typeId,kUTTagClassMIMEType);
+ if (!mimeType) {
// special case for m4a
- if ([(NSString*)typeId rangeOfString: @"m4a-audio"].location != NSNotFound){
+ if ([(__bridge NSString*)typeId rangeOfString: @"m4a-audio"].location != NSNotFound){
mimeType = @"audio/mp4";
} else if ([[fullPath pathExtension] rangeOfString:@"wav"].location != NSNotFound){
mimeType = @"audio/wav";
@@ -1250,8 +1232,7 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt: ( (bExists && bIsDir) ? 1 : 0 )];
// keep original format of returning 0 or 1 to success callback
- jsString = [result toSuccessCallbackString: callbackId];
- [fMgr release];
+ jsString = [result toSuccessCallbackString: callbackId];;
[self writeJavascript: jsString];
}
@@ -1272,19 +1253,4 @@ extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import)
}
--(void) dealloc
-{
- self.appDocsPath = nil;
- self.appLibraryPath = nil;
- self.appTempPath = nil;
- self.persistentPath = nil;
- self.temporaryPath = nil;
-
- [super dealloc];
-}
-
-
-
-
-
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVFileTransfer.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.h b/CordovaLib/Classes/CDVFileTransfer.h
index 3adbf37..d81cd13 100644
--- a/CordovaLib/Classes/CDVFileTransfer.h
+++ b/CordovaLib/Classes/CDVFileTransfer.h
@@ -59,8 +59,8 @@ extern NSString* const kOptionsKeyCookie;
@interface CDVFileTransferDelegate : NSObject {
}
-@property (retain) NSMutableData* responseData; // atomic
-@property (nonatomic, retain) CDVFileTransfer* command;
+@property (strong) NSMutableData* responseData; // atomic
+@property (nonatomic, strong) CDVFileTransfer* command;
@property (nonatomic, assign) CDVFileTransferDirection direction;
@property (nonatomic, copy) NSString* callbackId;
@property (nonatomic, copy) NSString* source;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m
index d020eda..d0cb145 100644
--- a/CordovaLib/Classes/CDVFileTransfer.m
+++ b/CordovaLib/Classes/CDVFileTransfer.m
@@ -101,7 +101,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
value = [NSArray arrayWithObject:value];
}
// Then, append all header values.
- for (id subValue in value) {
+ for (id __strong subValue in value) {
// Convert from an NSNumber -> NSString.
if ([subValue respondsToSelector:@selector(stringValue)]) {
subValue = [subValue stringValue];
@@ -240,7 +240,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
NSString* target = [command.arguments objectAtIndex:0];
NSString* server = [command.arguments objectAtIndex:1];
- CDVFileTransferDelegate* delegate = [[[CDVFileTransferDelegate alloc] init] autorelease];
+ CDVFileTransferDelegate* delegate = [[CDVFileTransferDelegate alloc] init];
delegate.command = self;
delegate.direction = CDV_TRANSFER_UPLOAD;
delegate.callbackId = command.callbackId;
@@ -251,9 +251,9 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
- (NSData*) fileDataForUploadCommand:(CDVInvokedUrlCommand*)command {
NSString* target = (NSString*)[command.arguments objectAtIndex:0];
- NSError *err = nil;
+ NSError* __autoreleasing err = nil;
// Extract the path part out of a file: URL.
- NSString* filePath = [target hasPrefix:@"/"] ? [[target copy] autorelease] : [[NSURL URLWithString:target] path];
+ NSString* filePath = [target hasPrefix:@"/"] ? [target copy] : [[NSURL URLWithString:target] path];
// Memory map the file so that it can be read efficiently even if it is large.
NSData* fileData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&err];
@@ -306,7 +306,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
[self applyRequestHeaders:nil toRequest:req];
- CDVFileTransferDelegate* delegate = [[[CDVFileTransferDelegate alloc] init] autorelease];
+ CDVFileTransferDelegate* delegate = [[CDVFileTransferDelegate alloc] init];
delegate.command = self;
delegate.direction = CDV_TRANSFER_DOWNLOAD;
delegate.callbackId = command.callbackId;
@@ -356,7 +356,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
BOOL downloadResponse;
NSMutableDictionary* uploadResult;
CDVPluginResult* result;
- NSError *error;
+ NSError* __autoreleasing error = nil;
NSString *parentPath;
BOOL bDirRequest = NO;
BOOL errored = NO;
@@ -387,7 +387,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
if(self.direction == CDV_TRANSFER_DOWNLOAD)
{
DLog(@"Write file %@", target);
- error=[[[NSError alloc]init] autorelease];
+ //error=[[NSError alloc]init];
if(self.responseCode >= 200 && self.responseCode < 300)
{
@@ -406,7 +406,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
} else {
DLog(@"File Transfer Download success");
- file = [[[CDVFile alloc] init] autorelease];
+ file = [[CDVFile alloc] init];
result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: [file getDirectoryEntry: target isDirectory: bDirRequest]];
}
@@ -426,8 +426,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
[self.command writeJavascript:[result toSuccessCallbackString: callbackId]];
} else {
[self.command writeJavascript:[result toErrorCallbackString: callbackId]];
- }
- [uploadResponse release];
+ }
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
@@ -486,17 +485,5 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
return self;
}
-- (void) dealloc
-{
- self.callbackId = nil;
- self.responseData = nil;
- self.command = nil;
- self.source = nil;
- self.target = nil;
-
- [super dealloc];
-}
-
-
@end;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVInvokedUrlCommand.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInvokedUrlCommand.m b/CordovaLib/Classes/CDVInvokedUrlCommand.m
index 677e5af..a75afdc 100644
--- a/CordovaLib/Classes/CDVInvokedUrlCommand.m
+++ b/CordovaLib/Classes/CDVInvokedUrlCommand.m
@@ -29,7 +29,7 @@
+ (CDVInvokedUrlCommand*) commandFromJson:(NSArray*)jsonEntry
{
- return [[[CDVInvokedUrlCommand alloc] initFromJson:jsonEntry] autorelease];
+ return [[CDVInvokedUrlCommand alloc] initFromJson:jsonEntry];
}
- (id) initFromJson:(NSArray*)jsonEntry
@@ -52,10 +52,10 @@
{
self = [super init];
if (self != nil) {
- _arguments = [arguments retain];
- _callbackId = [callbackId retain];
- _className = [className retain];
- _methodName = [methodName retain];
+ _arguments = arguments;
+ _callbackId = callbackId;
+ _className = className;
+ _methodName = methodName;
}
return self;
}
@@ -78,14 +78,4 @@
}
-- (void) dealloc
-{
- [_arguments release];
- [_callbackId release];
- [_className release];
- [_methodName release];
-
- [super dealloc];
-}
-
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVLocalStorage.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocalStorage.h b/CordovaLib/Classes/CDVLocalStorage.h
index d9a0235..1c10098 100644
--- a/CordovaLib/Classes/CDVLocalStorage.h
+++ b/CordovaLib/Classes/CDVLocalStorage.h
@@ -24,7 +24,7 @@
@interface CDVLocalStorage : CDVPlugin < UIWebViewDelegate >
-@property (nonatomic, readonly, retain) NSMutableArray* backupInfo;
+@property (nonatomic, readonly, strong) NSMutableArray* backupInfo;
- (BOOL) shouldBackup;
- (BOOL) shouldRestore;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVLocalStorage.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocalStorage.m b/CordovaLib/Classes/CDVLocalStorage.m
index 58686ba..f59cd08 100644
--- a/CordovaLib/Classes/CDVLocalStorage.m
+++ b/CordovaLib/Classes/CDVLocalStorage.m
@@ -22,8 +22,8 @@
@interface CDVLocalStorage ()
-@property (nonatomic, readwrite, retain) NSMutableArray* backupInfo; // array of CDVBackupInfo objects
-@property (nonatomic, readwrite, assign) id<UIWebViewDelegate> webviewDelegate;
+@property (nonatomic, readwrite, strong) NSMutableArray* backupInfo; // array of CDVBackupInfo objects
+@property (nonatomic, readwrite, unsafe_unretained) id<UIWebViewDelegate> webviewDelegate;
@end
@@ -60,7 +60,7 @@
backup = [backupsFolder stringByAppendingPathComponent:@"localstorage.appdata.db"];
- CDVBackupInfo* backupItem = [[[CDVBackupInfo alloc] init] autorelease];
+ CDVBackupInfo* backupItem = [[CDVBackupInfo alloc] init];
backupItem.backup = backup;
backupItem.original = original;
backupItem.label = @"localStorage database";
@@ -75,7 +75,7 @@
backup = [backupsFolder stringByAppendingPathComponent:@"websqlmain.appdata.db"];
- backupItem = [[[CDVBackupInfo alloc] init] autorelease];
+ backupItem = [[CDVBackupInfo alloc] init];
backupItem.backup = backup;
backupItem.original = original;
backupItem.label = @"websql main database";
@@ -90,7 +90,7 @@
backup = [backupsFolder stringByAppendingPathComponent:@"websqldbs.appdata.db"];
- backupItem = [[[CDVBackupInfo alloc] init] autorelease];
+ backupItem = [[CDVBackupInfo alloc] init];
backupItem.backup = backup;
backupItem.original = original;
backupItem.label = @"websql databases";
@@ -113,7 +113,7 @@
#pragma mark -
#pragma mark Plugin interface methods
-- (BOOL) copyFrom:(NSString*)src to:(NSString*)dest error:(NSError**)error
+- (BOOL) copyFrom:(NSString*)src to:(NSString*)dest error:(NSError* __autoreleasing*)error
{
NSFileManager* fileManager = [NSFileManager defaultManager];
@@ -132,7 +132,7 @@
// generate unique filepath in temp directory
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
- NSString* tempBackup = [[NSTemporaryDirectory() stringByAppendingPathComponent:(NSString*)uuidString] stringByAppendingPathExtension:@"bak"];
+ NSString* tempBackup = [[NSTemporaryDirectory() stringByAppendingPathComponent:(__bridge NSString*)uuidString]stringByAppendingPathExtension:@"bak"];
CFRelease(uuidString);
CFRelease(uuidRef);
@@ -192,7 +192,7 @@
{
NSString* callbackId = [arguments objectAtIndex:0];
- NSError* error = nil;
+ NSError* __autoreleasing error = nil;
CDVPluginResult* result = nil;
NSString* message = nil;
@@ -202,19 +202,21 @@
{
[self copyFrom:info.original to:info.backup error:&error];
- if (error == nil) {
- message = [NSString stringWithFormat:@"Backed up: %@", info.label];
- NSLog(@"%@", message);
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
- [self performSelectorOnMainThread:@selector(writeJavascript:) withObject:[result toSuccessCallbackString:callbackId] waitUntilDone:NO];
-
- } else {
- message = [NSString stringWithFormat:@"Error in CDVLocalStorage (%@) backup: %@", info.label, [error localizedDescription]];
- NSLog(@"%@", message);
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:message];
- [self performSelectorOnMainThread:@selector(writeJavascript:) withObject:[result toErrorCallbackString:callbackId] waitUntilDone:NO];
+ if (callbackId) {
+ if (error == nil) {
+ message = [NSString stringWithFormat:@"Backed up: %@", info.label];
+ NSLog(@"%@", message);
+
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
+ [self performSelectorOnMainThread:@selector(writeJavascript:) withObject:[result toSuccessCallbackString:callbackId] waitUntilDone:NO];
+
+ } else {
+ message = [NSString stringWithFormat:@"Error in CDVLocalStorage (%@) backup: %@", info.label, [error localizedDescription]];
+ NSLog(@"%@", message);
+
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:message];
+ [self performSelectorOnMainThread:@selector(writeJavascript:) withObject:[result toErrorCallbackString:callbackId] waitUntilDone:NO];
+ }
}
}
}
@@ -225,7 +227,7 @@
{
NSString* callbackId = [arguments objectAtIndex:0];
- NSError* error = nil;
+ NSError* __autoreleasing error = nil;
CDVPluginResult* result = nil;
NSString* message = nil;
@@ -336,10 +338,10 @@
backgroundTaskID = UIBackgroundTaskInvalid;
NSLog(@"Background task to backup WebSQL/LocalStorage expired.");
}];
-
+ CDVLocalStorage __unsafe_unretained *weakSelf = self;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [self backup:nil withDict:nil];
+ [weakSelf backup:nil withDict:nil];
[[UIApplication sharedApplication] endBackgroundTask: backgroundTaskID];
backgroundTaskID = UIBackgroundTaskInvalid;
@@ -380,12 +382,6 @@
#pragma mark -
#pragma mark Over-rides
-- (void) dealloc
-{
- self.backupInfo = nil;
-
- [super dealloc];
-}
@end
@@ -400,7 +396,7 @@
- (BOOL) file:(NSString*)aPath isNewerThanFile:(NSString*)bPath
{
NSFileManager* fileManager = [NSFileManager defaultManager];
- NSError* error = nil;
+ NSError* __autoreleasing error = nil;
NSDictionary* aPathAttribs = [fileManager attributesOfItemAtPath:aPath error:&error];
NSDictionary* bPathAttribs = [fileManager attributesOfItemAtPath:bPath error:&error];
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVLocation.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocation.h b/CordovaLib/Classes/CDVLocation.h
index 212eba2..d820c9c 100755
--- a/CordovaLib/Classes/CDVLocation.h
+++ b/CordovaLib/Classes/CDVLocation.h
@@ -42,10 +42,10 @@ typedef NSUInteger CDVLocationStatus;
}
@property (nonatomic, assign) CDVHeadingStatus headingStatus;
-@property (nonatomic, retain) CLHeading* headingInfo;
-@property (nonatomic, retain) NSMutableArray* headingCallbacks;
+@property (nonatomic, strong) CLHeading* headingInfo;
+@property (nonatomic, strong) NSMutableArray* headingCallbacks;
@property (nonatomic, copy) NSString* headingFilter;
-@property (nonatomic, retain) NSDate* headingTimestamp;
+@property (nonatomic, strong) NSDate* headingTimestamp;
@property (assign) NSInteger timeout;
@end
@@ -59,9 +59,9 @@ typedef NSUInteger CDVLocationStatus;
}
@property (nonatomic, assign) CDVLocationStatus locationStatus;
-@property (nonatomic, retain) CLLocation* locationInfo;
-@property (nonatomic, retain) NSMutableArray* locationCallbacks;
-@property (nonatomic, retain) NSMutableDictionary* watchCallbacks;
+@property (nonatomic, strong) CLLocation* locationInfo;
+@property (nonatomic, strong) NSMutableArray* locationCallbacks;
+@property (nonatomic, strong) NSMutableDictionary* watchCallbacks;
@end
@@ -72,9 +72,9 @@ typedef NSUInteger CDVLocationStatus;
CDVLocationData* locationData;
}
-@property (nonatomic, retain) CLLocationManager *locationManager;
-@property (retain) CDVHeadingData* headingData;
-@property (nonatomic, retain) CDVLocationData* locationData;
+@property (nonatomic, strong) CLLocationManager *locationManager;
+@property (strong) CDVHeadingData* headingData;
+@property (nonatomic, strong) CDVLocationData* locationData;
- (BOOL) hasHeadingSupport;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVLocation.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocation.m b/CordovaLib/Classes/CDVLocation.m
index 2d82372..87103a7 100755
--- a/CordovaLib/Classes/CDVLocation.m
+++ b/CordovaLib/Classes/CDVLocation.m
@@ -71,14 +71,6 @@
}
return self;
}
--(void) dealloc
-{
- self.headingInfo = nil;
- self.headingCallbacks = nil;
- self.headingFilter = nil;
- self.headingTimestamp = nil;
- [super dealloc];
-}
@end
@@ -96,13 +88,6 @@
}
return self;
}
--(void) dealloc
-{
- self.locationInfo = nil;
- self.locationCallbacks = nil;
- self.watchCallbacks = nil;
- [super dealloc];
-}
@end
@@ -118,7 +103,7 @@
self = (CDVLocation*)[super initWithWebView:(UIWebView*)theWebView];
if (self)
{
- self.locationManager = [[[CLLocationManager alloc] init] autorelease];
+ self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self; // Tells the location manager to send updates to this object
__locationStarted = NO;
__highAccuracyEnabled = NO;
@@ -271,7 +256,7 @@
[super writeJavascript:[result toErrorCallbackString:callbackId]];
} else {
if (!self.locationData) {
- self.locationData = [[[CDVLocationData alloc] init] autorelease];
+ self.locationData = [[CDVLocationData alloc] init];
}
CDVLocationData* lData = self.locationData;
if (!lData.locationCallbacks) {
@@ -296,7 +281,7 @@
BOOL enableHighAccuracy = [[arguments objectAtIndex:2] boolValue];
if (!self.locationData) {
- self.locationData = [[[CDVLocationData alloc] init] autorelease];
+ self.locationData = [[CDVLocationData alloc] init];
}
CDVLocationData* lData = self.locationData;
@@ -399,7 +384,7 @@
} else {
// heading retrieval does is not affected by disabling locationServices and authorization of app for location services
if (!self.headingData) {
- self.headingData = [[[CDVHeadingData alloc] init] autorelease];
+ self.headingData = [[CDVHeadingData alloc] init];
}
CDVHeadingData* hData = self.headingData;
@@ -431,7 +416,7 @@
[super writeJavascript:[result toErrorCallbackString:callbackId]];
} else {
if (!hData) {
- self.headingData = [[[CDVHeadingData alloc] init] autorelease];
+ self.headingData = [[CDVHeadingData alloc] init];
hData = self.headingData;
}
if (hData.headingStatus != HEADINGRUNNING) {
@@ -613,9 +598,6 @@
- (void) dealloc
{
self.locationManager.delegate = nil;
- self.locationManager = nil;
- self.headingData = nil;
- [super dealloc];
}
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVMotion.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVMotion.m b/CordovaLib/Classes/CDVMotion.m
index de94334..397393d 100644
--- a/CordovaLib/Classes/CDVMotion.m
+++ b/CordovaLib/Classes/CDVMotion.m
@@ -70,9 +70,5 @@
return [result isEqualToString:@"true"];
}
-- (void)dealloc
-{
- [super dealloc];
-}
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVNotification.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVNotification.h b/CordovaLib/Classes/CDVNotification.h
index 1de926e..24b2f8a 100644
--- a/CordovaLib/Classes/CDVNotification.h
+++ b/CordovaLib/Classes/CDVNotification.h
@@ -36,6 +36,4 @@
}
@property(nonatomic, copy) NSString* callbackId;
--(void) dealloc;
-
@end
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVNotification.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVNotification.m b/CordovaLib/Classes/CDVNotification.m
index 8f7a06c..f0e5005 100644
--- a/CordovaLib/Classes/CDVNotification.m
+++ b/CordovaLib/Classes/CDVNotification.m
@@ -59,7 +59,6 @@
}
[alertView show];
- [alertView release];
}
- (void) confirm:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
@@ -105,10 +104,5 @@
@synthesize callbackId;
-- (void) dealloc
-{
- self.callbackId = nil;
- [super dealloc];
-}
@end
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a6b67bea/CordovaLib/Classes/CDVPlugin.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin.h b/CordovaLib/Classes/CDVPlugin.h
index b3f9c7c..edb8b6f 100644
--- a/CordovaLib/Classes/CDVPlugin.h
+++ b/CordovaLib/Classes/CDVPlugin.h
@@ -28,10 +28,10 @@
@interface CDVPlugin : NSObject {
}
-@property (nonatomic, retain) UIWebView* webView;
-@property (nonatomic, retain) NSDictionary* settings;
-@property (nonatomic, retain) UIViewController* viewController;
-@property (nonatomic, retain) id<CDVCommandDelegate> commandDelegate;
+@property (nonatomic, strong) UIWebView* webView;
+@property (nonatomic, strong) NSDictionary* settings;
+@property (nonatomic, strong) UIViewController* viewController;
+@property (nonatomic, strong) id<CDVCommandDelegate> commandDelegate;
@property (readonly, assign) BOOL hasPendingOperation;