swiftuionappear

Is there a way to force an onAppear to update again?


I have an onAppear statement which is working fine when the view first loads:

.onAppear(){
    getData(from: "https://api.data/address/\(dataSettings.dataname)/storage/\(dataSettings.storagename)") { result in
        self.content = result
    }
}

However, when the user navigates away to a settings page and changes some information, this onAppear (correctly) does not update again. Is there something I can replace this with to cause the content to update if the settings information is updated?


Solution

  • .task(id: dataSettings) will happen on appear and when settings change