Ios 我的出口没有被引用

Ios 我的出口没有被引用,ios,swift3,xcode8,Ios,Swift3,Xcode8,虽然我按住ctrl键并拖动,但它会被引用…但当我运行应用程序时,它会因NSException崩溃。。。当我检查它时,它说我的视图控制器没有名为gif view的插座,并且在视图控制器上没有定义操作检查互联网。以下是我的视图控制器代码 import UIKit extension UIViewController{ func checkreachability() { if currentReachabilityStatus == .notReachable {

虽然我按住ctrl键并拖动,但它会被引用…但当我运行应用程序时,它会因NSException崩溃。。。当我检查它时,它说我的视图控制器没有名为gif view的插座,并且在视图控制器上没有定义操作检查互联网。以下是我的视图控制器代码

import UIKit

extension UIViewController{
func checkreachability()
{
    if currentReachabilityStatus == .notReachable
    {
        let alert = UIAlertController(title: "No Internet ", message: "Please Check Your Internet Connection", preferredStyle: UIAlertControllerStyle.alert)

        // add an action (button)
        alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))

        // show the alert
        self.present(alert, animated: true, completion: nil)
    }
}
视图控制器:

class ViewController: UIViewController {

  @IBOutlet weak var gifview: UIImageView!

  override func viewDidLoad() {
    super.viewDidLoad()

    gifview.loadGif(name: "source")
    // 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.
  }

  @IBAction func check_internet(_ sender: UIButton) { 
    checkreachability()
  }

}

删除对
ViewController.swift
的引用。然后将其重新添加到项目中,清理并重新构建。

不要创建弱引用。 因为弱引用不能保存
从您的
@IBOutlet
中删除薄弱部分,然后重试

检查您的插座是否正确连接并删除旧插座。@nithinsampath您确定
视图控制器
类在情节提要的“类”字段中给出了吗?另外,请确保没有多个名为“ViewController”的类。很抱歉……因为我是一个noob……请详细说明@DSDharmaYes我绝对确定…@BaliDid更新XCode后发生了什么?您正在处理图像。但您引用的属性很弱,因此它无法保存数据。这就是为什么你会崩溃