Skip to content

Instantly share code, notes, and snippets.

@bill1m
Last active February 27, 2020 13:30
Show Gist options
  • Save bill1m/dac4ca29bfe231724ccd040d6bc9ad8a to your computer and use it in GitHub Desktop.
Save bill1m/dac4ca29bfe231724ccd040d6bc9ad8a to your computer and use it in GitHub Desktop.
Unable to infer complex closure return type; add explicit type to disambiguate
// DestinationsView.swift
// PdfDocumentBrowser
//
// Created by Bill Morrison on 2/22/20.
// Copyright © 2020 Bill Morrison. All rights reserved.
//
import SwiftUI
import PDFKit
struct DestinationsView: View {
let destinations: [PDFDestination]
let lastPoint: NSPoint
var body: some View {
var ppoint: NSPoint = lastPoint
return ScrollView {
VStack(alignment: .leading) {
/// Unable to infer complex closure return type; add explicit type -> LineView to disambiguate
ForEach(destinations, id: \.self) { destination -> LineView in
let line = LineView(destination: destination, lastPoint: ppoint)
ppoint = destination.point
return line
}
}
}
}
}
struct DestinationsView_Previews: PreviewProvider {
static var previews: some View {
DestinationsView(destinations: AppDelegate.appData.getDestinations(doc: AppDelegate.appData.document).reversed(), lastPoint: NSPoint(x: 0, y: 0))
}
}
struct LineView: View {
let destination: PDFDestination
let lastPoint: NSPoint
var body: some View {
HStack {
Text(NSStringFromPoint(destination.point))
Text(NSStringFromPoint(lastPoint))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment