小编M.M*_*asa的帖子

使用PHPhotoLibrary API保存大量文件时出现异常

我的应用程序具有在tmp文件夹中下载许多照片和视频文件的功能,并使用PHPhotoLibrary API将它们保存在相机胶卷中.

问题是有时(概率大约为10%)异常发生在保存过程中.

控制台中的错误消息是,

由于未捕获的异常'NSInternalInconsistencyException'终止应用程序,原因:'此方法只能从 - [PHPhotoLibrary performChanges:completionHandler:]或 - [PHPhotoLibrary performChangesAndWait:error:]'内部调用

我的代码如下:

- (void)saveVideoFileInCameraRoll:(NSString *)videoFilePath
{
    NSURL *videoFileUrl = [NSURL fileURLWithPath:videoFilePath];

    photoLibrarySaveImageCompletion completion = ^(BOOL success, NSError *error) {
        NSLog(@"success=%@, error=%@", (success ? @"YES" : @"NO"), error);
    };

    NSLog(@"videoFileUrl=%@", videoFileUrl);

    [self saveVideoFile:videoFileUrl completion:completion];
}

- (void)saveVideoFile:(NSURL *)fileURL completion:(photoLibrarySaveImageCompletion)completion
{
    NSLog(@"fileURL=%@", fileURL);

    [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
        NSLog(@"fileURL=%@", fileURL);

        // Exception happens on this line as [SIGABRT]
        PHAssetChangeRequest *assetChangeRequest = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:fileURL]; 

        if (_assetCollection) {
            PHAssetCollectionChangeRequest *assetCollectionChangeRequest =
                [PHAssetCollectionChangeRequest changeRequestForAssetCollection:self.assetCollection];
            [assetCollectionChangeRequest addAssets:@[ [assetChangeRequest …
Run Code Online (Sandbox Code Playgroud)

exception objective-c ios phphotolibrary

7
推荐指数
0
解决办法
673
查看次数

使用USB MSC或MTP(大容量存储或媒体传输协议)的iOS应用程序

目前,我正在考虑以下iOS应用程序,

应用程序:使用闪电的USB3相机适配器,通过MSC(大容量存储类)或MTP(媒体传输协议),浏览文件并将文件从具有USB连接器的设备复制到iPhone。

闪电USB3相机适配器

http://www.apple.com/jp/shop/product/MK0W2AM/A/lightning-usb-3 ???????

我问苹果公司(TSI,技术支持事件)创建了这样的iOS应用程序,他们说iOS SDK不支持MSC / MTP。

通过使用Apple的USB主机适配器(Lightning USB3相机适配器),是否可以通过MSC或MTP通过USB电缆创建应用程序来浏览所连接设备中的文件?

如果您能回答问题或给我一些信息,我们将不胜感激。

谢谢。

iphone usb usb-mass-storage ios mtp

5
推荐指数
0
解决办法
785
查看次数