简体   繁体   中英

Save image file path to Core Data

After much research about the best way to save an image to a sqlite db in iOS, i've decided to save the filepath of the image in an entity and just reference it when it comes to displaying it as a thumbnail.

I'm using the following code to save the image taken with the camera:

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)snagPhoto editingInfo:(NSDictionary *)editingInfo
{
    [self.library saveImage:snagPhoto toAlbum:@"Snags" withCompletionBlock:^(NSError *error) {

        if (error) 
        {  
            NSLog(@"error");  
        } 
    }];  

    [picker dismissModalViewControllerAnimated:NO];
}

All I need to do is get the filepath of 'snagPhoto'.

ALAssetsLibrary上使用的正确方法是writeImageToSavedPhotosAlbum:metadata:completionBlock:writeImageToSavedPhotosAlbum:orientation:completionBlock: -这些将导致资产URL,您以后可以将其与assetForURL:resultBlock:failureBlock:以获取对图像的引用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM