Closed ghost closed 9 years ago
Hi @ChrisOSX , thx for ur feedback. I just take a look at ur question, but sorry i'm not very clear about it. B.t.w., have u installed the latest version (1.2.0) of this lib?
When you download the zip from the main page, the version in the project is 1.1.3, is there a newer version?
When I first started using your lib, calling this below would function in saving and creating the folder i named: [self.library saveImage:image toAlbum:@"" withCompletionBlock:^(NSError *error) { if (error!=nil) { NSLog(@"Big error: %@", [error description]); } }];
As mentioned in a couple other issues about recreating deleted folders on ios 8 there was a fix in the lib. I unfortunately do not have much experience using blocks and for the life of me figure out the completion and failure portion. [self.library saveImage:image toAlbum:@"insanelyi" completion:?? failure:?? { }];
When you download the zip from the main page, the version in the project is 1.1.3, is there a newer version?
Yes, the demo project's version is v1.1.3, should be right. it's
As mentioned in a couple other issues about recreating deleted folders on ios 8 there was a fix in the lib. I unfortunately do not have much experience using blocks and for the life of me figure out the completion and failure portion. [self.library saveImage:image toAlbum:@"insanelyi" completion:?? failure:?? { }];
Yeah, the latest lib uses -saveImage:toAlbum:completion:failure:
now, and there's a demo project in the lib, u can take a look at it:
...
// The completion block to be executed after image taking action process done
void (^completion)(NSURL *, NSError *) = ^(NSURL *assetURL, NSError *error) {
if (error) NSLog(@"!!!ERROR, write the image data to the assets library (camera roll): %@",
[error description]);
NSLog(@"*** URL %@ | %@ || type: %@ ***", assetURL, [assetURL absoluteString], [assetURL class]);
// Add new item to |photos_| & table view appropriately
NSIndexPath * indexPath = [NSIndexPath indexPathForRow:self.photos.count
inSection:0];
[self.photos addObject:[assetURL absoluteString]];
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView insertRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationFade];
});
};
void (^failure)(NSError *) = ^(NSError *error) {
if (error == nil) return;
NSLog(@"!!!ERROR, failed to add the asset to the custom photo album: %@", [error description]);
};
// Save image to custom photo album
// The lifetimes of objects you get back from a library instance are tied to
// the lifetime of the library instance.
[self.assetsLibrary saveImage:finalImageToSave
toAlbum:kKYCustomPhotoAlbumName_
completion:completion
failure:failure];
...
Do you see anything wrong in how I'm calling it here? I'm sending the image to self.library saveImage:image, so I don't think i need to declare anything else in the completion block.
NSURL *imageURL = receivedURL;
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]];
NSString *albumName = @"folder";
// The completion block to be executed after image taking action process done
void (^completion)(NSURL *, NSError *) = ^(NSURL *assetURL, NSError *error) {
if (error) NSLog(@"!!!ERROR, write the image data to the assets library (camera roll): %@",
[error description]);
NSLog(@"*** URL %@ | %@ || type: %@ ***", assetURL, image, [assetURL class]);
};
void (^failure)(NSError *) = ^(NSError *error) {
if (error == nil) return;
NSLog(@"!!!ERROR, failed to add the asset to the custom photo album: %@", [error description]);
};
[self.library saveImage:image
toAlbum:albumName
completion:completion
failure:failure];
Seems okay, but need to confirm with u about two issues below:
SDWebImage
or AFNetworking
's image category), there's a completion block to be invoked after loading the image succeed.self.library
initialized before u use it? If not, u need to alloc an instance for it.Alright if you think it's ok. I just didn't know if I needed to add anything else.
I only brought it up to begin with because a tester I have said it wouldn't recreate the folder.
Yeah, if those two are right, I guess it should works now. Take a try, and u might need to update the ui to let user know that the image saved succeed. :)
Sweet :) Yah I have a nice popup letting users know it's been downloaded. I appreciate all of the help. If everything looks good to you, then we can close this issue for now.
Sure, let me know if u still got the problem to let it work. Thx :)
While I used this library flawlessly on my previous builds, iOS 8 has given me trouble as mentioned in a few other issues, yet I can't grasp it.
My question is posted here: https://stackoverflow.com/questions/27585750/alassetslibrary-customphotoalbum-ios-8