TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
NZAssetsLibrary is a ALAssetsLibrary extension. This class save, delete and load images from specific album or device folder.
NZAssetsLibrary works on iOS 5.0+ and is compatible with ARC projects. It depends on the following Apple frameworks, which should already be included with most Xcode templates:
You will need LLVM 3.0 or later in order to build NZAssetsLibrary.
To build the sample is necessary iOS 6+ (sample project use UICollectionViewController
class).
The sample project uses AGPhotoBrowser.
Alternatively you can directly add source files to your project.
NZAssetsLibrary
folder onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project.#import "NZAssetsLibrary.h"
...
UIImage *image = [UIImage imageNamed:@"image.png"];
// NZAssetsLibrary unique instance
NZAssetsLibrary *assetsLibrary = [NZAssetsLibrary defaultAssetsLibrary];
// save image at album
[assetsLibrary saveImage:image toAlbum:@"Album name" withCompletion:^(NSError *error) {
if (error) {
NSLog(@"Failed to save image.");
return;
}
NSLog(@"Image saved successfully.");
}];
// save image at device document directory
[assetsLibrary saveJPGImageAtDocumentDirectory:image];
[assetsLibrary savePNGImageAtDocumentDirectory:image];
#import "NZAssetsLibrary.h"
#import "NZAssetImageFile.h"
...
// NZAssetsLibrary unique instance
NZAssetsLibrary *assetsLibrary = [NZAssetsLibrary defaultAssetsLibrary];
// load images from album
[assetsLibrary loadImagesFromAlbum:@"My Album" withCallback:^(NSArray<NZAssetImageFile> *assets, NSError *error) {
if (error) {
NSLog(@"Could not load images.");
return;
}
NSLog(@"Loaded successfully.");
}];
// load images from device document directory
NSArray<NZAssetImageFile> *array = [assetsLibrary loadImagesFromDocumentDirectory];
#import "NZAssetsLibrary.h"
#import "NZAssetFile.h"
...
NZAssetFile *file = ...;
// NZAssetsLibrary unique instance
NZAssetsLibrary *assetsLibrary = [NZAssetsLibrary defaultAssetsLibrary];
[assetsLibrary deleteFile:file];
This code is distributed under the terms and conditions of the MIT license.
A brief summary of each NZAssetsLibrary release can be found on the wiki.