2016-03-22 10 views
0

prepareForSqueの次のビューコントローラにselectedFocusを送信するにはどうすればよいですか? (または、prepareForSequeでセグメント化されたコントロールボタンのどの部分に基づいて変数を割り当てるか)"Use of unresolved identifier 'segmentedControlVariable"は私のエラーです。あなたのthirdviewcontrollerのSegmented Control変数を準備するにはどうすればよいですか?

class SecondSignUpViewController: UIViewController { 

    // DECLARATIONS... 

    // user's focus to be sent to next view contr. 
    var selectedFocus = String() 

    // 1. LOAD IN SENT VARS (so that it exists in this view) (at top it seems oposed to in viewdidload?...) 
    var passedPassword_toView2:String! 
    var passedUsername_toView2:String! 
    var passedEmail_toView2:String! 

    @IBAction func continueButtonPressed2(sender: AnyObject) { 
     performSegueWithIdentifier("SegueAfterJoin2", sender: self) 
    } 



@IBAction func indexChanged(sender: AnyObject) { 
    switch segmentedControl.selectedSegmentIndex { 
    case 0: 
     print("case0") 
     textLabel.text = "You are a music artist who needs services."; 
     imageShown.image = image0 
     selectedFocus = "artist" 
    case 1: 
     print("case1") 
     textLabel.text = "You want to share your talent with music artists."; 
     imageShown.image = image1 
     selectedFocus = "provider" 
    default: 
     break; 
    } 
} 

// VAR SHIFT 
// GET FROM PREV. VIEW 
override func viewDidLoad() { 
    super.viewDidLoad() 
    print("view 2 loaded") 

    // 2. (for ease,) TRANSFER TO VAR NAMES 
    var myLocalPassword = passedPassword_toView2 
    var myLocalUsername = passedUsername_toView2 
    var myLocalEmail = passedEmail_toView2 

} 

// 3. SEND VARS TO NEW VIEW 
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) { 
    if (segue.identifier == "SegueAfterJoin2") { 
     var nextViewCont = segue!.destinationViewController as! ThirdSignUpViewController; 

     // PASS VARS FROM THIS VIEW TO NEXT 
     nextViewCont.passedPassword_toView3 = passedPassword_toView2 
     nextViewCont.passedEmail_toView3 = passedUsername_toView2 
     nextViewCont.passedUsername_toView3 = passedEmail_toView2 

     //how can I toss this in too? 
     nextViewCont.passedFocus_toView3 = selectedfocus 

    } 
} 
+0

と呼ばれるあなたが今直面している問題は何ですか?あなたは他のtoView2 varsを渡すようにselectedFocusをnextViewContに渡しますか? –

+0

はいこれに近づける方法がわかりません –

+0

"未解決の識別子 'segmentedControlVariable'の使用は私が得るエラーです –

答えて

1

あなたが最初のビューコントローラに

ようpassedFocus_toView3変数

行うに作成され、この

override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) { 
    if (segue.identifier == "YourSegueName") { 
     //get a reference to the destination view controller 
     let destinationVC:ViewControllerClass = segue.destinationViewController as! ViewControllerClass 

     //set properties on the destination view controller 
     destinationVC.passedFocus_toView3 = selectedfocus 
     //etc... 
    } 
} 
関連する問題