0

I'm wondering whats wrong with my code at this point. After trying a lot I figured out how to pass a UIAlert over...kind of.. But I get errors. Another pair of eyes would be great for some advice. Source code would be great. Thanks in advance code is below. I just put the part of the code that I need to transfer over. I haven't finished writing the the "didfinishRecievingResource"; because I got stuck at this point. If this is not possible can you let me know that way I can take a different route. Again thank you for even looking at this . I am also using xcode 8. THANKS MULTIPEER CONNECTION

    func session(_ session: MCSession, didStartReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, with progress: Progress) {
   self.newAlert(title: "HI", message: "Player 1 !")


  func newAlert (title: String, message:String)
 {
      let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: output.text, style: UIAlertActionStyle.default, handler: { (action) in

}))
self.present(alert,animated: true, completion:nil)

}

}

}
jake
  • 15
  • 5

1 Answers1

0

Change your UIAlert like below

// alert box
    func newAlert(title: String, message: String) {

        let alertController = UIAlertController(title: title, message:
            message, preferredStyle: UIAlertControllerStyle.alert)

        alertController.addAction(UIAlertAction(title: output.text, style: UIAlertActionStyle.default,handler: nil))

        self.present(alertController, animated: true, completion: nil)
    }
Alwin
  • 1,476
  • 3
  • 19
  • 35
  • @Alwin...Thanks for the reply. What does this do exactly? – jake May 22 '17 at 08:09
  • Here we create a alertController, and give actions to it. Here we give a single action thats title is "output.text". The alertBox work when a viewDidAppear. Is this answer helped, then mark this as best answer. – Alwin May 22 '17 at 08:28