how to pass data after pop view controller in swift
<p>I am making an app about book.
In the app,
i want to make the app auto-filling book info by getting ISBN(Barcode)</p>

<p><a href="http://i.stack.imgur.com/ohz2S.png" rel="nofollow">views</a></p>

<p>There is 2 classes.
one is 'UploadMain',the other is 'ScanView'</p>

<p>I can get ISBN by scanning,
but i have a problem to pass data from ScanView to UploadMain.</p>

<p>In ScanView i have used optional Binding like below</p>

<pre><code>if let UploadVC = self.storyboard?.instantiateViewControllerWithIdentifier("UploadMain") as? UploadMain {
     UploadVC.ISBNstring = self.detectionString!
}
</code></pre>

<p><strong>Code for UploadMain Class</strong></p>

<pre><code>override func viewDidLoad(){
    super.viewDidLoad()
    ISBN.delegate = self

}

override func viewWillAppear(animated: Bool){
    ISBN.text = ISBNstring
}
</code></pre>

<p>i don't know whats the problem my code.</p>

<p>Full Code of <strong>UploadMain</strong></p>

<pre><code>import UIKit
import Foundation

class UploadMain: UIViewController,UITextFieldDelegate {


var ISBNstring: String = ""
var TitleString: String = ""
var AuthorString: String = ""
var PubString: String = ""
var PriceSting: String = ""

@IBOutlet weak var ISBN: UITextField!

@IBOutlet weak var bookTitle: UITextField!

@IBOutlet weak var bookAuthor: UITextField!

@IBOutlet weak var bookPub: UITextField!

@IBOutlet weak var bookPrice: UITextField!



override func viewDidLoad(){
    super.viewDidLoad()
    ISBN.delegate = self
}

override func viewWillAppear(animated: Bool){
    ISBN.text = ISBNstring
}



@IBAction func Upload(sender: AnyObject) {
    dismissViewControllerAnimated(true, completion: nil)
}
}
</code></pre>

<p><strong>ScanView class</strong>  </p>

<pre><code>import UIKit
import AVFoundation
import Foundation


class ScanView : UIViewController, AVCaptureMetadataOutputObjectsDelegate {



let session         : AVCaptureSession = AVCaptureSession()
var previewLayer    : AVCaptureVideoPreviewLayer!
var detectionString : String!
let apiKey : String = "---------dddddd"


override func viewDidLoad() {
    super.viewDidLoad()

    // For the sake of discussion this is the camera
    let device = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)

    // Create a nilable NSError to hand off to the next method.
    // Make sure to use the "var" keyword and not "let"
    var error : NSError? = nil
    var input: AVCaptureDeviceInput = AVCaptureDeviceInput()
    do {
        input = try  AVCaptureDeviceInput(device: device) as AVCaptureDeviceInput
    } catch let myJSONError {
        print(myJSONError)
    }

    // If our input is not nil then add it to the session, otherwise we're kind of done!
    if input !=  AVCaptureDeviceInput() {
        session.addInput(input)
    }
    else {
        // This is fine for a demo, do something real with this in your app. :)
        print(error)
    }

    let output = AVCaptureMetadataOutput()
    output.setMetadataObjectsDelegate(self, queue: dispatch_get_main_queue())
    session.addOutput(output)
    output.metadataObjectTypes = output.availableMetadataObjectTypes


    previewLayer = AVCaptureVideoPreviewLayer(session: session)
    previewLayer.frame = self.view.bounds
    previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
    self.view.layer.addSublayer(previewLayer)

    // Start the scanner. You'll have to end it yourself later.
    session.startRunning()

}



// This is called when we find a known barcode type with the camera.
func captureOutput(captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [AnyObject]!, fromConnection connection: AVCaptureConnection!) {

    var highlightViewRect = CGRectZero
    var barCodeObject : AVMetadataObject!
    let barCodeTypes = [AVMetadataObjectTypeEAN13Code, AVMetadataObjectTypeEAN8Code]


    // The scanner is capable of capturing multiple 2-dimensional barcodes in one scan.
    for metadata in metadataObjects {

        for barcodeType in barCodeTypes {

            if metadata.type == barcodeType {
                barCodeObject = self.previewLayer.transformedMetadataObjectForMetadataObject(metadata as! AVMetadataMachineReadableCodeObject)

                highlightViewRect = barCodeObject.bounds

                detectionString = (metadata as! AVMetadataMachineReadableCodeObject).stringValue

                self.session.stopRunning()

                self.alert(detectionString)

                // Daum Book API 호출
                let apiURI = NSURL(string: "https://apis.daum.net/search/book?apikey=\(apiKey)&amp;q=\(detectionString)&amp;searchType=isbn&amp;output=json")

                let apidata : NSData? = NSData(contentsOfURL: apiURI!)

                NSLog("API Result = %@", NSString(data: apidata!, encoding: NSUTF8StringEncoding)!)

                **if let UploadVC = self.storyboard?.instantiateViewControllerWithIdentifier("UploadMain") as? UploadMain {
                    UploadVC.ISBNstring = self.detectionString!
                }**

                break
            }

        }
    }

    print(detectionString)
    self.navigationController?.popViewControllerAnimated(true)

}



func alert(Code: String){
    let actionSheet:UIAlertController = UIAlertController(title: "Barcode", message: "\(Code)", preferredStyle: UIAlertControllerStyle.Alert)

    // for alert add .Alert instead of .Action Sheet
    // start copy
    let firstAlertAction:UIAlertAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler:
        {
            (alertAction:UIAlertAction!) in

            // action when pressed
            self.session.startRunning()
    })


    actionSheet.addAction(firstAlertAction)

}

}
</code></pre>