[英]Cannot assign value of type '[String]' to type 'String?' error Swift
[英]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.