2014-05-23 7 views
0

전무 문자열 매개 변수 :UIDocumentInteractionController 내가 이런 식으로 등 이미지, 녹음, 비디오를 표시 할 UIDocumentInteractionController를 사용하고

NSURL *URL = [[NSBundle mainBundle] URLForResource:@"2013-08-01 13_20_44 (id)" withExtension:@"mov"]; 

또는 그런

NSData* dataFile = [dict objectForKey:@"FileData"]; 
    NSString *urlString = [[NSString alloc] initWithData:dataFile encoding:NSUTF8StringEncoding]; // Or any other appropriate encoding 
    NSURL *URL = [[NSURL alloc] initWithString:urlString]; 

:

if (URL) { 
     // Initialize Document Interaction Controller 
     documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL]; 

     // Configure Document Interaction Controller 
     [documentInteractionController setDelegate:self]; 

     // Preview PDF 
     [documentInteractionController presentPreviewAnimated:YES]; 
    } 

으로 mainBundle에서 문서에 액세스하고 때로는 작동하지만 때로는 followin을 얻습니다. g 오류 :있는 NSData 방법으로

2014-05-23 12:25:54.648 Cleverly[362:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initWithString:relativeToURL:]: nil string parameter' 

, 나는 항상 (내가 다른 방법으로 미세을 열 수있는 NSData이 손상되지) 그것을 얻을.

1) 이유가 무엇인가요? 2) 충돌을 방지하려면 어떻게해야합니까? 3) 오류는 무엇을 의미합니까? (왜 mainBundle의 일부 리소스에서는 작동하지만 다른 리소스에서는 작동하지 않는 이유는 무엇입니까?)

if(nil != urlString) 
{ 
    NSURL *URL = [[NSURL alloc] initWithString:urlString]; 
} 

나 : 어떤 도움

+0

메시지에서 'urlString' 매개 변수가 nil이므로 NSURL -initWithString :'에서 충돌을 일으킴 –

답변

0

충돌이 명시된 바와 같이, 충돌을 피하기 위해 URLString는, nil을 반환하는 논리의 경우 다음과 같은 조건을 추가하십시오있을 수 있습니다 사전에

감사합니다 잘못된 urlString을 반환하는 근본 원인을 찾습니다.