2013-07-29 3 views
0

File-> Save 명령을 사용하여 성공적으로 저장할 수있는 NSDocument 하위 클래스가 있습니다.코코아 saveToURL이 작동하지 않습니까?

내 응용 프로그램이 특정 작업을 실행할 때이 파일을 업데이트하고 업데이트 된 파일을 디스크에 자동 저장해야합니다. 나는 다음을 모두 시도했다 :

//Attempt #1. No error but document in not saved to disk. 
NSError * theError; 
[myDocument invalidateRestorableState]; //mark document as dirty 
[myDocument writeSafelyToURL:[myDocument fileURL] ofType:CONSTANT_CONTAINING_FILE_EXTENSION forSaveOperation:NSAutosaveInPlaceOperation error:&theError]; 
if (theError != nil) 
    [NSApp presentError:theError]; 

//Attempt #2. Completion handler is not called. Doc is not saved to disk. 
[myDocument saveToURL:[myDocument fileURL] ofType:CONSTANT_CONTAINING_FILE_EXTENSION forSaveOperation:NSAutosaveInPlaceOperation completionHandler:^(NSError *errorOrNil) { 
if (errorOrNil != nil) 
     [NSApp presentError:errorOrNil]; 
}]; 

//Attempt #3. No error but doc is not saved to disk. 
NSError * theError; 
[myDocument saveToURL:[myDocument fileURL] ofType:CONSTANT_CONTAINING_FILE_EXTENSION forSaveOperation:NSSaveOperation error:&theError]; 
if (theError != nil) 
    [NSApp presentError:theError]; 

//Attempt #4. didSaveDocument is not called. Doc is not saved to disk. 
[myDocument saveDocumentWithDelegate:myDocument didSaveSelector:@selector(didSaveDocument:didSave:contextInfo:) contextInfo:nil]; 

myDocument가 존재하고이 호출이 이루어질 때 업데이트 된 데이터를 포함한다.

무엇이 누락 되었습니까?

모든 정보를 미리 알려 주셔서 감사합니다.

답변

0

나는 그것을 발견했다고 생각한다. fileURL이 잘못되었습니다.