簡體   English   中英

我收到錯誤消息=無法分配類型為'String'的值? 鍵入“ [String]”我到處都是,我似乎找不到答案

[英]Im getting the error = Cannot assign value of type 'String?' to type '[String]' Ive looked everywhere and i can't seem to find the answer

import UIKit

class FirstViewController: UIViewController
 {

    @IBOutlet var Dishname: UILabel!

    @IBOutlet var TEXT: UITextField!

    @IBOutlet var recipy: UIView!



    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

        let secondVC: SecondViewController = segue.destinationViewController as! SecondViewController


        secondVC.items = TEXT.text! as? String    //Error

// Cannot assign value of type 'String?' to type '[String]'

    }

SecondViewController中的items變量是[Array]類型的字符串數組,您嘗試為其分配字符串,而不是在其中插入或追加。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM