简体   繁体   English

“该操作无法完成。 仅将图像发送到icloud时,“不允许操作”错误

[英]“The operation couldn’t be completed. Operation not permitted” error when simply sending image to icloud

Im simply trying to upload this image to iCloud. 我只是试图将此图像上传到iCloud。 It keeps giving me the error "The operation couldn't be completed. Operation not permitted". 它一直给我错误“无法完成操作。不允许操作”。 I took this code right out of the Document Based App Programming Guide and I believe I've set all my certificates, identifiers, profiles, and entitlements correctly. 我直接从基于文档的应用程序编程指南中删除了此代码,并且我相信我已经正确设置了所有证书,标识符,配置文件和权利。 Any help would be much appreciated. 任何帮助将非常感激。 This is insanely frustrating. 这真是令人沮丧。

#import "docx.h"

@implementation docx

-(IBAction)test:(id)sender{

    NSURL *src = [NSURL URLWithString:@"/Users/rjm226/Desktop/jh.jpg"];
        NSLog(@"%@", src);

    NSURL *dest = NULL;

    NSURL *ubiquityContainerURL = [[[NSFileManager defaultManager]
                                    URLForUbiquityContainerIdentifier:nil]
                                   URLByAppendingPathComponent:@"Documents"];

    if (ubiquityContainerURL == nil) {
        NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: NSLocalizedString(@"iCloud does not appear to be configured.", @""),
                              NSLocalizedFailureReasonErrorKey, nil];

        NSError *error = [NSError errorWithDomain:@"Application" code:404
                                         userInfo:dict];

        [self presentError:error modalForWindow:[self windowForSheet] delegate:nil didPresentSelector:NULL contextInfo:NULL];

        return;
    }

    dest = [ubiquityContainerURL URLByAppendingPathComponent:
            [src lastPathComponent]];

    //Move file to iCloud

    dispatch_queue_t globalQueue =
    dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

    dispatch_async(globalQueue, ^(void) {

        NSFileManager *fileManager = [[NSFileManager alloc] init];

        NSError *error = nil;
        // Move the file.

        BOOL success = [fileManager setUbiquitous:YES itemAtURL:src
                                   destinationURL:dest error:&error];

        dispatch_async(dispatch_get_main_queue(), ^(void) {
            if (! success) {
                [self presentError:error modalForWindow:[self windowForSheet]
                          delegate:nil didPresentSelector:NULL contextInfo:NULL];
            }
        });
    });
}

@end

This is insanely frustrating. 这真是令人沮丧。

Welcome to iCloud. 欢迎使用iCloud。 You'll get used to that feeling after a while. 一段时间后,您会习惯这种感觉。 In the meantime though, you have other problems. 同时,您还有其他问题。

NSURL *src = [NSURL URLWithString:@"/Users/rjm226/Desktop/jh.jpg"];

This is not going to give you a valid URL, which is going to be a problem. 这不会为您提供有效的URL,这将是一个问题。 What you need is: 您需要的是:

NSURL *src = [NSURL fileURLWithPath:@"/Users/rjm226/Desktop/jh.jpg"];

That will give you a valid file:// URL. 这将为您提供一个有效的file:// URL。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 该操作无法完成。 可可错误4 - The operation couldn’t be completed. Cocoa Error 4 MidiClientCreate“操作无法完成。 (OSStatus错误-50。)” - MidiClientCreate “The operation couldn't be completed. (OSStatus error -50.)” 该操作无法完成。 (可可错误:3840。) - The Operation couldn't be completed. (Cocoa error: 3840.) “这项行动无法完成。 (可可错误512.)“ - “The operation couldn’t be completed. (Cocoa error 512.)” ITLibrary:无法完成操作。 (OSStatus 错误 7011。) - ITLibrary: The operation couldn’t be completed. (OSStatus error 7011.) 导致iOS iCloud错误的原因:错误Domain = BRCloudDocsErrorDomain Code = 12“操作无法完成。”延迟后重试:60 - What causes iOS iCloud error: Error Domain=BRCloudDocsErrorDomain Code=12 “The operation couldn’t be completed.” Retrying after delay: 60 该操作无法完成。 (可可错误1560.) - The operation couldn’t be completed. (Cocoa error 1560.) 收到错误消息“操作无法完成。 (com.facebook.sdk错误5。)',当从iphone在Facebook上发布视频时 - Getting error 'The operation couldn’t be completed. (com.facebook.sdk error 5.)' when Posting video on facebook from iphone 操作无法完成。 对等方重置连接 - The operation couldn’t be completed. Connection reset by peer CloudKit:CKQuery显示错误:错误:操作无法完成。 (CKErrorDomain错误1。) - CloudKit : CKQuery showing error: error: The operation couldn’t be completed. (CKErrorDomain error 1.)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM