Segmented button and modal view

I need help from anyone who can point me in the right direction, I’d appreciate it.

I have a segmented control. When the 3rd button is tapped, I want a modal view to appear that requests information from the user. When DONE, the value entered should be returned to the calling view. Here’s what the segmented control code looks like.

@IBAction func createAndAppendItem(_ sender: Any) {
//  When button 0 is tapped, append a constant value onto an array
//  When button 1 is tapped, compute a value and append it to an array
//  When button 2 is tapped, suspend the calling thread, display a popup view,
//       have the user enter a value into a text field using a decimal pad,
//       when the user clicks DONE, return the entered value, resume the calling thread
//       and append the user entered value onto the array.

    var item: Float = 0.0
    var itemArray: [Float] = []

    @IBAction func createAndAppendItem(_ sender: Any) {
        switch createAndAppendItemControl.selectedSegmentIndex {
        item = -1.0
        case 0:  // append a constant
            item = 3.14159
        case 1:  // append a computed value
            item = elsewhereCode()
        case 2:  // append a user entered value
            // pause here
            // display a view (keypad, picker, whatever, maybe as a popup)
            // dismiss that view and return the user entered value
            // assign *that* value to item and resume
        default:
            item = 0.0
        }
    itemArray.append(item)
    }

I’ve tried creating a segue from the calling view to the popup view. I’ve tried CTRL-dragging from the 3rd button of the segmented control to the popup view. I can get a view to display, but the calling view doesn’t wait for the popup to be dismissed. It just keeps executing and falls thru the switch. How do I call a simple popup and wait for its return value before continuing. Basically, I want to popup to behave like a function.