Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed delegate methods to be compatible with swift #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CRMediaPickerController/CRMediaPickerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ typedef NS_OPTIONS(NSInteger, CRMediaPickerControllerSourceType) {
@protocol CRMediaPickerControllerDelegate <NSObject>

@optional
- (void)CRMediaPickerController:(CRMediaPickerController *)mediaPickerController didFinishPickingAsset:(ALAsset *)asset error:(NSError *)error;
- (void)CRMediaPickerControllerDidCancel:(CRMediaPickerController *)mediaPickerController;
- (void)mediaPickerController:(CRMediaPickerController *)mediaPickerController didFinishPickingAsset:(ALAsset *)asset error:(NSError *)error;
- (void)mediaPickerControllerDidCancel:(CRMediaPickerController *)mediaPickerController;
@end

@interface CRMediaPickerController: NSObject
Expand Down
68 changes: 34 additions & 34 deletions CRMediaPickerController/CRMediaPickerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ - (void)show

- (void)dismiss
{
if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerControllerDidCancel:)]) {
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerControllerDidCancel:)]) {
[self.imagePickerController.presentingViewController dismissViewControllerAnimated:YES completion:^{
[self.delegate CRMediaPickerControllerDidCancel:self];
[self.delegate mediaPickerControllerDidCancel:self];
}];
} else {
[self.imagePickerController.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
Expand Down Expand Up @@ -361,8 +361,8 @@ - (void)getLastMediaTaken

if (group.numberOfAssets == 0) {

if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerController:didFinishPickingAsset:error:)]) {
[self.delegate CRMediaPickerController:self didFinishPickingAsset:nil error:nil];
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerController:didFinishPickingAsset:error:)]) {
[self.delegate mediaPickerController:self didFinishPickingAsset:nil error:nil];
}

} else {
Expand All @@ -372,8 +372,8 @@ - (void)getLastMediaTaken
return;
}

if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerController:didFinishPickingAsset:error:)]) {
[self.delegate CRMediaPickerController:self didFinishPickingAsset:asset error:nil];
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerController:didFinishPickingAsset:error:)]) {
[self.delegate mediaPickerController:self didFinishPickingAsset:asset error:nil];
}

*innerStop = YES;
Expand All @@ -385,8 +385,8 @@ - (void)getLastMediaTaken

} failureBlock:^(NSError *error) {

if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerController:didFinishPickingAsset:error:)]) {
[self.delegate CRMediaPickerController:self didFinishPickingAsset:nil error:error];
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerController:didFinishPickingAsset:error:)]) {
[self.delegate mediaPickerController:self didFinishPickingAsset:nil error:error];
}

}];
Expand All @@ -407,8 +407,8 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger
} else if ([buttonTitle isEqualToString:NSLocalizedString(@"Saved Photos", nil)]) {
sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else if ([buttonTitle isEqualToString:NSLocalizedString(@"Cancel", nil)]) {
if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerControllerDidCancel:)]) {
[self.delegate CRMediaPickerControllerDidCancel:self];
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerControllerDidCancel:)]) {
[self.delegate mediaPickerControllerDidCancel:self];
}
return;
}
Expand All @@ -423,8 +423,8 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker.presentingViewController dismissViewControllerAnimated:YES completion:^{
if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerControllerDidCancel:)]) {
[self.delegate CRMediaPickerControllerDidCancel:self];
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerControllerDidCancel:)]) {
[self.delegate mediaPickerControllerDidCancel:self];
}
}];
}
Expand All @@ -450,19 +450,19 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking

[assetsLibrary assetForURL:assetURL resultBlock:^(ALAsset *asset) {

if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerController:didFinishPickingAsset:error:)]) {
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerController:didFinishPickingAsset:error:)]) {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:^{
[self.delegate CRMediaPickerController:self didFinishPickingAsset:asset error:nil];
[self.delegate mediaPickerController:self didFinishPickingAsset:asset error:nil];
}];
} else {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
}

} failureBlock:^(NSError *err) {

if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerController:didFinishPickingAsset:error:)]) {
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerController:didFinishPickingAsset:error:)]) {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:^{
[self.delegate CRMediaPickerController:self didFinishPickingAsset:nil error:err];
[self.delegate mediaPickerController:self didFinishPickingAsset:nil error:err];
}];
} else {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
Expand All @@ -472,9 +472,9 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking

} else {

if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerController:didFinishPickingAsset:error:)]) {
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerController:didFinishPickingAsset:error:)]) {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:^{
[self.delegate CRMediaPickerController:self didFinishPickingAsset:nil error:error];
[self.delegate mediaPickerController:self didFinishPickingAsset:nil error:error];
}];
} else {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
Expand All @@ -488,19 +488,19 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking

[assetsLibrary assetForURL:referenceURL resultBlock:^(ALAsset *asset) {

if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerController:didFinishPickingAsset:error:)]) {
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerController:didFinishPickingAsset:error:)]) {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:^{
[self.delegate CRMediaPickerController:self didFinishPickingAsset:asset error:nil];
[self.delegate mediaPickerController:self didFinishPickingAsset:asset error:nil];
}];
} else {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
}

} failureBlock:^(NSError *error) {

if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerController:didFinishPickingAsset:error:)]) {
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerController:didFinishPickingAsset:error:)]) {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:^{
[self.delegate CRMediaPickerController:self didFinishPickingAsset:nil error:error];
[self.delegate mediaPickerController:self didFinishPickingAsset:nil error:error];
}];
} else {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
Expand Down Expand Up @@ -531,19 +531,19 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking

[assetsLibrary assetForURL:assetURL resultBlock:^(ALAsset *asset) {

if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerController:didFinishPickingAsset:error:)]) {
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerController:didFinishPickingAsset:error:)]) {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:^{
[self.delegate CRMediaPickerController:self didFinishPickingAsset:asset error:nil];
[self.delegate mediaPickerController:self didFinishPickingAsset:asset error:nil];
}];
} else {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
}

} failureBlock:^(NSError *err) {

if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerController:didFinishPickingAsset:error:)]) {
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerController:didFinishPickingAsset:error:)]) {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:^{
[self.delegate CRMediaPickerController:self didFinishPickingAsset:nil error:err];
[self.delegate mediaPickerController:self didFinishPickingAsset:nil error:err];
}];
} else {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
Expand All @@ -553,9 +553,9 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking

} else {

if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerController:didFinishPickingAsset:error:)]) {
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerController:didFinishPickingAsset:error:)]) {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:^{
[self.delegate CRMediaPickerController:self didFinishPickingAsset:nil error:error];
[self.delegate mediaPickerController:self didFinishPickingAsset:nil error:error];
}];
} else {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
Expand All @@ -569,19 +569,19 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking

[assetsLibrary assetForURL:[info objectForKey:UIImagePickerControllerReferenceURL] resultBlock:^(ALAsset *asset) {

if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerController:didFinishPickingAsset:error:)]) {
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerController:didFinishPickingAsset:error:)]) {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:^{
[self.delegate CRMediaPickerController:self didFinishPickingAsset:asset error:nil];
[self.delegate mediaPickerController:self didFinishPickingAsset:asset error:nil];
}];
} else {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
}

} failureBlock:^(NSError *error) {

if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerController:didFinishPickingAsset:error:)]) {
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerController:didFinishPickingAsset:error:)]) {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:^{
[self.delegate CRMediaPickerController:self didFinishPickingAsset:nil error:error];
[self.delegate mediaPickerController:self didFinishPickingAsset:nil error:error];
}];
} else {
[picker.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
Expand Down Expand Up @@ -624,8 +624,8 @@ - (UIPopoverController *)makePopoverController:(UIImagePickerController *)picker
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
self.popoverController = nil;
if (self.delegate && [self.delegate respondsToSelector:@selector(CRMediaPickerControllerDidCancel:)]) {
[self.delegate CRMediaPickerControllerDidCancel:self];
if (self.delegate && [self.delegate respondsToSelector:@selector(mediaPickerControllerDidCancel:)]) {
[self.delegate mediaPickerControllerDidCancel:self];
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "E78B529B3E29A73BEA7969FC7095F6CA65F46FD5",
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {

},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
"40069BF539098AEF7FE1C2D5534EA7025ADAA3D8" : 0,
"E78B529B3E29A73BEA7969FC7095F6CA65F46FD5" : 0
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "DB07EAAC-C230-425D-82CD-65FBC4DDE1AD",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"40069BF539098AEF7FE1C2D5534EA7025ADAA3D8" : "",
"E78B529B3E29A73BEA7969FC7095F6CA65F46FD5" : "CRMediaPickerController\/"
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "Example",
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "Example\/Example.xcodeproj",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:SnowdogApps\/SDForms.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "40069BF539098AEF7FE1C2D5534EA7025ADAA3D8"
},
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:dulal0026\/CRMediaPickerController.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "E78B529B3E29A73BEA7969FC7095F6CA65F46FD5"
}
]
}
4 changes: 2 additions & 2 deletions Example/Example/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ - (IBAction)takePictureViewButtonTapped:(id)sender

#pragma mark - CPDMediaPickerControllerDelegate

- (void)CRMediaPickerController:(CRMediaPickerController *)mediaPickerController didFinishPickingAsset:(ALAsset *)asset error:(NSError *)error
- (void)mediaPickerController:(CRMediaPickerController *)mediaPickerController didFinishPickingAsset:(ALAsset *)asset error:(NSError *)error
{
if (!error) {

Expand Down Expand Up @@ -196,7 +196,7 @@ - (void)CRMediaPickerController:(CRMediaPickerController *)mediaPickerController
}
}

- (void)CRMediaPickerControllerDidCancel:(CRMediaPickerController *)mediaPickerController
- (void)mediaPickerControllerDidCancel:(CRMediaPickerController *)mediaPickerController
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ If `sourceType` property has multiple sources, it presents a UIActionSheet with

### Delegate Methods

A `CRMediaPickerController` instance will return the selected media file back to `CRMediaPickerControllerDelegate`. The delegate contains methods very similar to the `UIImagePickerControllerDelegate`. Instead of returning one dictionary representing a single image the controller sends back the original `ALAsset` object which are easy to deal with.
A `CRMediaPickerController` instance will return the selected media file back to `mediaPickerControllerDelegate`. The delegate contains methods very similar to the `UIImagePickerControllerDelegate`. Instead of returning one dictionary representing a single image the controller sends back the original `ALAsset` object which are easy to deal with.

* **Finished Picking Asset**

`- CRMediaPickerController:didFinishPickingAsset:error:`
`- mediaPickerController:didFinishPickingAsset:error:`

Tells the delegate that the picking process is done and the media file is ready to use.

```objc
- (void)CRMediaPickerController:(CRMediaPickerController *)mediaPickerController didFinishPickingAsset:(ALAsset *)asset error:(NSError *)error;
- (void)mediaPickerController:(CRMediaPickerController *)mediaPickerController didFinishPickingAsset:(ALAsset *)asset error:(NSError *)error;
```

Parameters:
Expand All @@ -164,12 +164,12 @@ Parameters:

* **Cancelled**

`- CRMediaPickerControllerDidCancel:`
`- mediaPickerControllerDidCancel:`

Tells the delegate that the user cancelled the picking process.

```objc
- (void)CRMediaPickerControllerDidCancel:(CRMediaPickerController *)mediaPickerController;
- (void)mediaPickerControllerDidCancel:(CRMediaPickerController *)mediaPickerController;
```

Parameters:
Expand All @@ -188,7 +188,7 @@ Parameters:
```objc
#pragma mark - CPDMediaPickerControllerDelegate

- (void)CRMediaPickerController:(CRMediaPickerController *)mediaPickerController didFinishPickingAsset:(ALAsset *)asset error:(NSError *)error
- (void)mediaPickerController:(CRMediaPickerController *)mediaPickerController didFinishPickingAsset:(ALAsset *)asset error:(NSError *)error
{
if (!error) {

Expand Down Expand Up @@ -227,7 +227,7 @@ Parameters:
}
}

- (void)CRMediaPickerControllerDidCancel:(CRMediaPickerController *)mediaPickerController
- (void)mediaPickerControllerDidCancel:(CRMediaPickerController *)mediaPickerController
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
Expand Down