• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iOS 8.4: Converting a URL into a PHAsset
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iOS 8.4: Converting a URL into a PHAsset


  • Subject: Re: iOS 8.4: Converting a URL into a PHAsset
  • From: Carl Hoefs <email@hidden>
  • Date: Wed, 29 Jul 2015 08:47:07 -0700

> On Jul 28, 2015, at 11:59 PM, Ben Kennedy <email@hidden> wrote:
>
> On 28 Jul 2015, at 7:17 pm, Carl Hoefs <email@hidden> wrote:
>>
>> I'm trying to get an NSURL into PHAsset form, but I keep coming up with null. PHAsset fetchAssetsWithALAssetURLs: takes an NSArray of NSURLs: "An array of NSURL objects, each an asset URL previously retrieved from an ALAsset object." Apparently, this is not a simple array of NSURL objects.
>
> Well, more specifically, it sounds like an array of “asset URLs previously retrieved from an ALAsset object.”
>
>> 2015-07-28 19:04:36.221 hsvst[577:76956] assetURLs (
>>   "file:///var/mobile/Containers/Data/Application/9C51BEE6-80A7-15A4-72DA-19E447A75E25/Documents/hsvst_0005.mov"
>> )
>
> Indeed, that looks like a file:// URL representing a path to regular disk file on the filesystem, not an asset URL from an ALAsset object.
>
> Have you looked at +[PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:] ?  For example:
>
>> PHAssetChangeRequest *assetRequest = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL: self.sourcePlayListItem.url];
>> PHObjectPlaceholder *assetPlaceholder = assetRequest.placeholderForCreatedAsset;
>> /* treat assetPlaceholder as a PHAsset and do something with it */ ;
>
> What are you ultimately trying to do?
>
Ultimately, I'm simply trying to delete the asset:
  [PHAssetChangeRequest deleteAssets:@[asset]];

You're right, of course, that I've overlooked the fine print: it wants an array of “asset URLs previously retrieved from an ALAsset object.” I'm not quite certain what that means, exactly.

I'm able to delete the asset by using:
  [[NSFileManager defaultManager] removeItemAtURL: self.sourcePlayListItem.url error:&error];
but I think the new 'photo asset' way is preferred in iOS8+, so I thought I'd try to be compliant.
-Carl



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: iOS 8.4: Converting a URL into a PHAsset
      • From: Ben Kennedy <email@hidden>
References: 
 >iOS 8.4: Converting a URL into a PHAsset (From: Carl Hoefs <email@hidden>)
 >Re: iOS 8.4: Converting a URL into a PHAsset (From: Ben Kennedy <email@hidden>)

  • Prev by Date: How to zoom with auto layout?
  • Next by Date: Re: Best way to have KVC-compliant enum property in Swift 2?
  • Previous by thread: Re: iOS 8.4: Converting a URL into a PHAsset
  • Next by thread: Re: iOS 8.4: Converting a URL into a PHAsset
  • Index(es):
    • Date
    • Thread