2013-05-25 7 views
0

간단히이 이미지를 iCloud에 업로드하려고합니다. 그것은 나에게 "작업을 완료 할 수 없습니다. 작업이 허용되지 않습니다."라는 오류를 계속 제공합니다. 이 코드를 Document Based App Programming Guide에서 가져 와서 모든 인증서, 식별자, 프로필 및 권한을 올바르게 설정했다고 생각합니다. 어떤 도움이라도 대단히 감사 할 것입니다. 이것은 매우 실망 스럽습니다.간단히 이미지를 icloud로 보낼 때 "작업을 완료 할 수 없습니다. 작업을 수행 할 수 없습니다"오류가 발생했습니다.

#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 

답변

1

이 굉장히 실망이다.

iCloud에 오신 것을 환영합니다. 잠시 후 그 느낌에 익숙해 질 것입니다. 그동안 다른 문제가 있습니다.

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

당신에게 문제가 될 것입니다 유효한 URL을 제공하지 않을. 당신은 무엇이 필요하다 : 당신에게 유효한 file:// URL을 줄 것이다

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

.

+0

고마워요. 이것은 문제를 해결하지 못했지만 확실히 코드에서 오류가있었습니다. – rjm226

관련 문제