는()?

2016-12-17 6 views
1

이 내 코드입니다. 그러나 오류가, 스위프트 3 년 ... 유형의 인수 목록에 NSCalendar.current 수익을는()?

let fromDate = NSDate(timeIntervalSince1970: TimeInterval(tweetsArray[indexPath.row].timestamp)!) 

     let toDate = NSDate() 

     let components : NSCalendar.Unit = [.second, .minute, .hour, .day, .weekOfMonth] 

     let differenceOfDate = NSCalendar.current.dateComponents(components, from: fromDate, to: toDate) 

답변

0

을 dateComponent를 호출 할 수 없습니다 말했다 재단 NSCalendar 유형의 신속한 값 래퍼 일종 인 Calendar.

dateComponents()Set<Calendar.Component>는 두 인자를 Date. Date가대한 신속한 값 랩퍼 타입 210. NSCalendar.currentCalender하지 NSCalendar를 반환하는 이유

기존 재단 API를 스위프트로 가져

는 유형이 있음을 자동으로 브리지됩니다. 그들은 적절한 값 의미를 제공 불변 가변 변형 letvar 대신 를 사용 때문에

값 유형 스위프트 (3)에 바람직하다.

모두 함께 퍼팅 :

let fromDate = Date(timeIntervalSince1970: ...) 
let toDate = Date() 
let components = Set<Calendar.Component>([.second, .minute, .hour, .day, .weekOfMonth]) 
let differenceOfDate = Calendar.current.dateComponents(components, from: fromDate, to: toDate) 

를 자세한 내용은 스위프트 3 값 래퍼 유형과 이에 상응하는 재단의 유형에 대해, SE-0069 Mutability and Foundation Value Types, 또는 Working with Cocoa Frameworks에 대해서는 "브리지 유형"을 참조하십시오 " Swift with Cocoa and Objective-C " 참조.

+0

감사합니다. Martin R ... – revi