2017-03-12 11 views
1

맥 OS 속성,
애플이 API 재단> 파일 관리자> setAttributes을 (이 swift3 _ : ofItemAtPath :를 사용하여 신속하고 맥 OS가

선언은 FUNC의 setAttributes (_ 속성입니다 : [FileAttributeKey : 어떤] , ofItemAtPath path : String) throw

파일의 생성 날짜 등을 설정하기위한 것입니다. > ofItem path : String)을 처리 할 수 ​​있지만 <을 던졌습니다. 그러나 첫 번째 부분은 저를 곤란하게합니다.

API는 'true'를 반환 할 수 있지만 신속한 반환은 무효라고합니다. 'creationDate'라는 속성이 있습니다. 밑줄 '_'의 의미는 무엇입니까?
내가 생각하는 '속성'나는 많은 변화를 시도 변경 가능한 사전

var myAttributesDictionary = [FileAttributeKey : Date]() 
myAttributesDictionary[FileAttributeKey.creationDate] = myDateObject 

let fm = FileManger() 
let xxx = fm.setAttributes(myAttributesDictionary:[FileAttributeKey : creationDate], ofItemAtPath myPath) 

이며, 지금은 난처한 상황에 빠진, 그리고 난이 필요 모르겠어요. 컴파일 할 setAttributes 행을 가져올 수 없습니다.

답변

0

질문을 게시하기 전에 잠시 보냈습니다. 내 질문을 찾을 때 대답을 찾았습니다.

let mypath = "/path/to/file" 
let myDateObject = NSDate()  // NSDate() is todays date 

let attributes = [FileAttributeKey.creationDate: myDateObject] 

do { 
     try FileManager.default.setAttributes(attributes, ofItemAtPath: myPath) 
    } 
    catch 
    { 
     print(error) 
    }