IOS gets the picture name from the album, intercepts the suffix, the picture name

Source: Internet
Author: User

Get the full file name (with suffix) from the path to the image taken from the album, the video is valid.

NSString *filename = [FilePath lastpathcomponent];

Get filename (without suffix)

NSString *filename1 = [FilePath stringbydeletingpathextension];

Get the suffix name of the file (without '. ') )

NSString *suffix = [FilePath pathextension];

get the picture name Pro test only valid for the picture

Nsurl *refurl = [info valueforkey:uiimagepickercontrollerreferenceurl];

Define the block to call when we get the asset based on the URL (below)

Alassetslibraryassetforurlresultblock Resultblock = ^ (Alasset *imageasset)

{

Alassetrepresentation *imagerep = [Imageasset defaultrepresentation];

Dnlog (@ "[imagerep filename]:%@", [imagerep filename]);

};

Get the asset library and fetch the asset based on the ref URL (pass in block above)

alassetslibrary* assetslibrary = [[Alassetslibrary alloc] init];

[Assetslibrary Assetforurl:refurl Resultblock:resultblock Failureblock:nil];

[Picker Dismissviewcontrolleranimated:yes Completion:nil];

IOS gets the picture name from the album, intercepts the suffix, the picture name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.