Wednesday, August 7, 2019

Xcode 11 beta 5 SwiftUI changes


NavigationButton  becomes  NavigationLink  Select all
NavigationButton( destination: LandmarkDetail(landmark: landmark)) { LandmarkRow(landmark: landmark) }

NavigationButton  becomes  NavigationLink  Select all
NavigationLink( destination: LandmarkDetail(landmark: landmark) .environmentObject(self.userData) ) { LandmarkRow(landmark: landmark) }


ForEach  .identified by:  Select all
ForEach(["iPhone SE", "iPhone XS Max"].identified(by: \.self)) { deviceName in LandmarkList() .previewDevice(PreviewDevice(rawValue: deviceName)) .previewDisplayName(deviceName) } .environmentObject(UserData())

ForEach  id:  Select all
ForEach(["iPhone SE", "iPhone XS Max"], id: \.self) { deviceName in LandmarkList() .previewDevice(PreviewDevice(rawValue: deviceName)) .previewDisplayName(deviceName) } .environmentObject(UserData())



BindableObject  becomes  ObservableObject  Select all
final class UserData: BindableObject { let didChange = PassthroughSubject<UserData, Never>() var showFavoritesOnly = false { didSet { didChange.send(self) } } var landmarks = landmarkData { didSet { didChange.send(self) } } }

BindableObject  becomes  ObservableObject  Select all
final class UserData: ObservableObject { @Published var showFavoritesOnly = false @Published var landmarks = landmarkData }


No comments: