Skip to content

Commit

Permalink
Update comments for quick look
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkhoyt committed Jul 9, 2015
1 parent 774344f commit 690e6c7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 30 deletions.
51 changes: 33 additions & 18 deletions PHAsset+Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
// Copyright (c) 2014 Zakk Hoyt. All rights reserved.
//




#import <Foundation/Foundation.h>

@import Photos;

typedef void (^PHAssetBoolBlock)(BOOL success);
Expand All @@ -18,29 +14,48 @@ typedef void (^PHAssetAssetBoolBlock)(PHAsset *asset, BOOL success);

@interface PHAsset (Utilities)

// Save a copy of a PHAsset to a specific album
/*!
@method saveToAlbum:completionBlock
@description Save a copy of a PHAsset to a photo album. Will create the album if it doesn't exist.
@param title The title of the album.
@param completionBlock This block is passed a BOOL for success. This parameter may be nil.
*/
-(void)saveToAlbum:(NSString*)title completionBlock:(PHAssetBoolBlock)completionBlock;

// Get metadata dictionary of an asset (the kind with {Exif}, {GPS}, etc...
/*!
@method requestMetadataWithCompletionBlock
@description Get metadata dictionary of an asset (the kind with {Exif}, {GPS}, etc...
@param completionBlock This block is passed a dictionary of metadata properties. See ImageIO framework for parsing/reading these. This parameter may be nil.
*/
-(void)requestMetadataWithCompletionBlock:(PHAssetMetadataBlock)completionBlock;

// Update the location and date of an existing asset
/*!
@method updateLocation:creationDate:completionBlock
@description Update the location and date of an existing asset
@param location A CLLocation object to be written to the PHAsset. See CoreLocation framework for obtaining locations.
@param creationDate An NSDate to be written to the PHAsset.
@param completionBlock This block is passed the PHAsset updated with location/date (if applied) and BOOL for success. This parameter may be nil.
*/
-(void)updateLocation:(CLLocation*)location creationDate:(NSDate*)creationDate completionBlock:(PHAssetBoolBlock)completionBlock;


// // Save an image to camera roll (returns PHAsset in completion block)
// UIImage *image = [UIImage imageNamed:@"terribleImage"];
// [PHAsset saveImageToApplicationAlbum:image location:nil completionBlock:^(PHAsset *asset, BOOL success) {
// NSLog(@"asset saved to camera roll");
// }];
/*!
@method saveImageToCameraRoll:location:completionBlock
@description Save an image to camera roll with optional completion (returns PHAsset in completion block)
@param location A CLLocation object to be written to the PHAsset. See CoreLocation framework for obtaining locations. This parameter may be nil.
@param creationDate An NSDate to be written to the PHAsset.
@param completionBlock Returns the PHAsset which was written and BOOL for success. This parameter may be nil.
*/
+(void)saveImageToCameraRoll:(UIImage*)image location:(CLLocation*)location completionBlock:(PHAssetAssetBoolBlock)completionBlock;

// // Save video to camera roll (returns PHAsset in completion block)
// NSURL *url = [NSURL urlWithString:@"terribleURL"];
// [PHAsset saveVideoAtURL:videoFileURL location:nil completionBlock:^(PHAsset *asset, BOOL success) {
// NSLog(@"asset saved to camera roll");
// }];
/*!
@method saveVideoAtURL:location:completionBlock
@description Save a video to camera roll with optional completion (returns PHAsset in completion block)
@param location A CLLocation object to be written to the PHAsset. See CoreLocation framework for obtaining locations. This parameter may be nil.
@param creationDate An NSDate to be written to the PHAsset.
@param completionBlock Returns the PHAsset which was written and BOOL for success. This parameter may be nil.
*/
+(void)saveVideoAtURL:(NSURL*)url location:(CLLocation*)location completionBlock:(PHAssetAssetBoolBlock)completionBlock;

@end


12 changes: 0 additions & 12 deletions PHAsset+Utility.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
// Copyright (c) 2014 Zakk Hoyt. All rights reserved.
//



#import "PHAsset+Utility.h"
@import Photos;

@implementation PHAsset (Utilities)

#pragma mark Public methods





-(void)saveToAlbum:(NSString*)title completionBlock:(PHAssetBoolBlock)completionBlock{
void (^saveAssetCollection)(PHAssetCollection *assetCollection) = ^(PHAssetCollection *assetCollection){
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
Expand All @@ -31,9 +25,7 @@ -(void)saveToAlbum:(NSString*)title completionBlock:(PHAssetBoolBlock)completion
}];
};


PHAssetCollection *assetCollection = [self albumWithTitle:title];

if(assetCollection){
// Album exists
saveAssetCollection(assetCollection);
Expand All @@ -49,8 +41,6 @@ -(void)saveToAlbum:(NSString*)title completionBlock:(PHAssetBoolBlock)completion
PHAssetCollection *assetCollection = [self albumWithTitle:title];
saveAssetCollection(assetCollection);
}


}];
}
}
Expand All @@ -68,7 +58,6 @@ -(void)requestMetadataWithCompletionBlock:(PHAssetMetadataBlock)completionBlock{
});
}


-(void)updateLocation:(CLLocation*)location creationDate:(NSDate*)creationDate completionBlock:(PHAssetBoolBlock)completionBlock{
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *assetRequest = [PHAssetChangeRequest changeRequestForAsset:self];
Expand Down Expand Up @@ -118,7 +107,6 @@ +(void)saveVideoAtURL:(NSURL*)url location:(CLLocation*)location completionBlock
}];
}


#pragma mark Private helpers

-(PHAssetCollection*)albumWithTitle:(NSString*)title{
Expand Down

0 comments on commit 690e6c7

Please sign in to comment.