title: How to present alert by code or in custom class in swiftui
body: <p>I have searched all document about how to present alert in swiftui, but they all show code like this: </p>
  
  <pre class="lang-swift prettyprint-override"><code>Button(action: {
              self.showingAlert = true
  }) {
              Text("Show Alert")
  }
  .alert(isPresented:$showingAlert) {
      Alert(title: Text("title"))
  }
  </code></pre>
  
  <p>Which means that alert must be used for button.</p>
  
  <p>How can I use alert in my custom class like handle http request and then show error alert like this:</p>
  
  <pre class="lang-swift prettyprint-override"><code>class A{
      func getDate(){
          alert("error")
      }
  }
  </code></pre>