Unable to infer complex closure return type with SwiftUI

后端 未结 5 1108
执念已碎
执念已碎 2020-12-17 09:35

Following part 3 of Apple\'s tutorial on SwiftUI, Handling User Input, I get this error:

Unable to infer complex closure return type; add explicit ty

5条回答
  •  粉色の甜心
    2020-12-17 10:38

    The issue is not with the closure, but with the isFavorite property on landmark.

    It is not declared on the Landmark type, and the compiler instead of showing the undeclared property error, unable to resolve the stacks build closure return type, so it shows and error there.

    Great job Apple tutorial writers and even better one Xcode11 compiler.

    To fix:

    1. Declare isFavorite variable on the Landmark type.
    2. Make sure you update the landmarkData.json for every landmark record with the isFavorite = false entry, otherwise the app will crash at runtime.

提交回复
热议问题