2017-04-02 1 views
0

그래서 여기에 제가하고있는 것이 있습니다. 다른 "탈것"이있는 테이블을 하나의 pageControllerView에 모두 링크 된 "ride cells"으로 만들었지 만, 특정 승차감에 대한 정적 정보 (var)에 연결하려고합니다. 즉, 테이블 뷰 RideCell을 클릭 할 때마다 페이지 뷰에 저장된 특정 '라이드'정보로 연결된다는 의미입니다 ...'[Page]'유형의 값을 예상되는 요소 유형 'Page'로 변환 할 수 없습니다.

오류는 Ride2에 있으며 "변환 할 수 없습니다"라는 메시지가 표시됩니다. 이 코드 줄의 끝으로 정보 [페이지] 구성 요소와 관련이 있다는 :

func setupRides() { 

    let ride2 = Ride(title: "Contacts", route: "", image: #imageLiteral(resourceName: "main"), info: [tron]) 
// let ride3 = Ride(title: "Pirates of the Caribbean", route: "Event", image: #imageLiteral(resourceName: "pirates"), info: [Page(title: "Pirates of the Caribbean", message: "Soaring Over the Horizon (FP)", imageName: "main")]) 

난 그냥 나머지 과정을 가져 전에 하나에서 작동하도록 노력하고 있어요.

다른 중요한 코드는 다음과 같이이 :

var tron: [Page] = { 
let firstPage = Page(title: "Share a great listen", message: "It's free to send your books to the people in your life. Every recipient's first book is on us.", imageName: "main") 
let secondPage = Page(title: "Send from your library", message: "Tap the More menu next to any book. Choose \"Send this Book\"", imageName: "main") 
let thirdPage = Page(title: "Send from the player", message: "Tap the More menu in the upper corner. Choose \"Send this Book\"", imageName: "main") 
return [firstPage, secondPage, thirdPage] 
}() 

이 내 라이드 및 페이지 클래스가 어떻게 생겼는지입니다.

class Ride { 
let title: String 
let route: String 
let image: UIImage 
let info: [Page] 

init(title: String, route: String, image: UIImage, info: [Page]){ 
    self.title = title 
    self.route = route 
    self.image = image 
    self.info = info 
} 
} 

class Page { 
let title: String 
let message: String 
let imageName: String 

init(title: String, message: String, imageName: String) { 
    self.title = title 
    self.message = message 
    self.imageName = imageName 
} 
} 

죄송합니다. 멍청한 질문입니다. RTFF를했는데 아직 찾지 못했습니다 ...

답변

0

[Page]으로 선언되었으므로 Page의 배열입니다.

[tron]을 수행 할 때 tron을 다른 배열에 넣습니다. 이제 [[Page]]Page 배열의 배열입니다. 그래서

간단하게 수행

let ride2 = Ride(title: "Contacts", route: "", image: #imageLiteral(resourceName: "main"), info: tron) 
관련 문제