-
Notifications
You must be signed in to change notification settings - Fork 16
/
PHAsset+Utility.h
61 lines (50 loc) · 3.13 KB
/
PHAsset+Utility.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// PHAsset+Utilities.h
//
// Created by Zakk Hoyt on 9/22/14.
// Copyright (c) 2014 Zakk Hoyt. All rights reserved.
//
#import <Foundation/Foundation.h>
@import Photos;
typedef void (^PHAssetBoolBlock)(BOOL success);
typedef void (^PHAssetMetadataBlock)(NSDictionary *metadata);
typedef void (^PHAssetAssetBoolBlock)(PHAsset *asset, BOOL success);
@interface PHAsset (Utilities)
/*!
@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;
/*!
@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;
/*!
@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;
/*!
@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;
/*!
@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