قالب وردپرس درنا توس
Home / IOS Development / Delegates pattern in SwiftUI: iOSProgramming

Delegates pattern in SwiftUI: iOSProgramming



Short questions: In UIKit we have delegated pattern, but how should I recognize clicks in nested view?

Far: For example, let's say we have a view that is a list of user addresses (AddressListView). In OrderVC we will only select the selected item on click, but on SettingsVC we will open new EditAdressVC to be able to change parameters.

In UIKit I just wanted to add AddressListViewDelegate to AddressListView and in didSelectCellAtRow I would call delegate.didSelectAddress (address). Then just click SettingsVC / OrderVC to do what I want.

How should I do it on SwiftUI? Pass delegate in unit, passport trades method on init, or add method to AddressListView like as onAppear, onDissapear?


Source link