Overwriting images in iPhoto app - ios

I have a feature in my iOS application. The user has the option to save photo or video to the iPhoto app. When the user presses the 'Save' button, it saves the photo or video again. Is there a way to overwrite the existing file instead of saving it again.
[self writeVideoAtPathToSavedPhotosAlbum:url completionBlock:^(NSURL* assetURL, NSError* error) {
//error handling
if (error!=nil) {
completionBlock(error);
return;
}
//add the asset to the custom photo album
[self addAssetURL: assetURL
withCompletionBlock:completionBlock];
}];
Any suggestion on this? Using checksum?

Looks like you can't, either you disable your Save button after click once or save to document directory and do checksum algorithm. Please check this answer check image exist

Related

Deezer iOS SDK - Play specific track from radio

I'm currently working with Deezer SDK to play a radio from deezer in my app.
Is possible to play a radio even if the user has not authorized my app.
Is there a way to play a specific track from a Radio?
I'm following this guide but it seems that this was possible in the old Sdk but not in the new.
In the old sdk there were also more Delegate methods such as
- (void)player:(PlayerFactory *)player timeChanged:(long)time
But my main goal would be to play a track from a radio, in order to be sure to not play the same track two times in a row.
Is there someone that knows how to accomplish my goal?
It's possible to play a radio even you aren't connected if you want you can take a look here :
https://developers.deezer.com/sdk/ios#player
At the section « Play a
radio without user connected (New Api)
Of course you can play a specific track from a radio,
a radio is like, a playlist or an album, it's a DZRObjectList.
From your DZRObjectList, you can call :
- (void)allObjectsWithManager:(DZRRequestManager *)manager callback:(void (^)(NSArray *objs, NSError *error))callback;
Every object should be a track, so you can achieve your goal by making a check directly on the array.
Best Regards,
EDIT
This is an example :
DZRRadio *yourDZRRadio;
DZRRequestManager *manager = [[DZRRequestManager defaultManager] subManager];
[yourDZRRadio valueForKey:#"tracks" withRequestManager:manager callback:^(DZRObjectList *objectList, NSError *error) {
if (objectList != nil) {
[objectList allObjectsWithManager:manager callback:^(NSArray *tracks, NSError *error) {
/*
* Here you have tracks from your radio so you can send it to your player :)
*/
}];
} else {
}
}];

Some Image cannot be saved using UIImageWriteToSavedPhotosAlbum to photo album

recently, I want to save some images from urls to the user photo album.
I use the function UIImageWriteToSavedPhotosAlbum, and the didFinishSavingWithError call back told me the result, my problem is if there is a lot urls of images,using this way, some images always cannot be saved to the album even its already download from url.
As I checked the size offailed saved image , it is a png, 1290 × 1288, I don`t know if it is because of the size is too big too save. Do you guys have this kind of issues? please help~thanks!
UIImageWriteToSavedPhotosAlbum(image, self,#selector(image:didFinishSavingWithError:contextInfo:), nil);
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
if (error != nil) {
isImagesSavedFailed = true;
}
}
You might want to try to write them one by one instead of in parallel. Especially since you have many pictures. You are letting it become "too busy." So you'll want to queue them up and write not all at once.
You can get some more details at ios programming: Using threads to add multiple images to library

Disable confirmation on delete request in PHPhotoLibrary delete Assets?

My question is how can I disable confirmation on delete request on [PHAssetChangeRequest deleteAssets:assets], if my application created that assets , so my app should able to delete assets without confirmation?
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ [PHAssetChangeRequest deleteAssets:assets];
} completionHandler:^(BOOL success, NSError *error)
{
NSLog(#"Finished deleting asset. %#", (success ? #"Success." : error.description));
}];
Thanks..
At the moment where the file is saved, it belongs to the system.
So if you want to remove this file later, the user will always be informed by a message.
It's part of the PHPhotoLibrary.. I know it's suck.

How to host content externally on Parse?

I want to pack a lot of products into one for Black Friday.
The upload limit # Parse is 10 MB and I need to upload 145 MB. How can I re-route a download to an external hosted content without releasing a new version of my app?
I Hope you can Answer this soon.
It's really important for us to put this Black Friday offer in place.
EDIT:
OK, now I Know I'll Need to Update my App to Download the Content externally. Does Anyone have the Code on how to Download the Content From an External Host Instead of Parse once the Purchase is Approved? THANKS
What I'm Doing now is:
// FOR THE PURCHASE:
[PFPurchase buyProduct:<ProductID> block:^(NSError *error) {
if (!error) {
// run UI logic that informs user the product has been purchased, such as displaying an alert view.
[SVProgressHUD showWithStatus:#"Downloading..."];
}else
{
NSLog(#"ERROR: %#", error);
[SVProgressHUD showErrorWithStatus:#"Error"];
}
}];
// AND EARLIER....
// adding the Purchase Observer
[PFPurchase addObserverForProduct:<ProductID> block:^(SKPaymentTransaction *transaction) {
[PFPurchase downloadAssetForTransaction:transaction completion:^(NSString *filePath, NSError *error) {
if (!error) {
// Unzipping
//...... AND SAVING THE FILES, ETC.....
}
}];
// Thanks Stack-Overflowers
If your App is actually getting the images out of Parse, then you are stuck with the 10 MB limit unfortunately. In order to get around that you would need to store the URL to the image in Parse and host the image somewhere else. Unfortunately you would need to modify your App in the code to handle the URL which will require another release.
It seems like the only thing you can do at this point is to reduce the quality or dimensions of your images to shrink the file size to < 10 MB.

Preview of dropbox file in iOS

I am integrating dropbox with my IOS application. I am able to fetch selected file meta data. But couldn't find the way to show preview after selecting the file. Can someone suggest which API is helpful.
Drop box i am using is : https://www.dropbox.com/developers/dropins/chooser/ios
Below piece of code is called when user wants to select file from dropbox :
- (void)didPressChoose
{
[[DBChooser defaultChooser] openChooserForLinkType:DBChooserLinkTypePreview fromViewController:self
completion:^(NSArray *results)
{
if ([results count]) {
_result = results[0];
//After getting the result, i want to preview the file
} else {
_result = nil;
[[[UIAlertView alloc] initWithTitle:#"CANCELLED" message:#"user cancelled!"
delegate:nil cancelButtonTitle:#"Okay" otherButtonTitles:nil]
show];
}
[[self tableView] reloadData];
}];
}
When you ask for DBChooserLinkTypePreview, the DBChooserResult you get back from the Chooser will have an NSURL link like this:
https://www.dropbox.com/s/toyzur6e0m34t7v/dropbox-logos_dropbox-glyph-blue.png
This link type is meant for direct user interaction, so you can send a user there and Dropbox will display the page with a preview of the file if possible.
Alternatively, you may want to use DBChooserLinkTypeDirect which gives you a direct link like this:
https://dl.dropboxusercontent.com/1/view/969vkzdys770277/Testing/Images/dropbox-logos_dropbox-glyph-blue.png
This is a direct (but temporary) link to the file contents. You can download the file contents programmatically (e.g., see How do I download and save a file locally on iOS using objective C? ) and then do whatever you want with it. For example, you may want to display it in an UIImageView if it's an image, etc.
Also, DBChooserResult contains a thumbnails property with links to thumbnails (if the selected file was an image or video) that might be similarly useful.

Resources